www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - SDL Error: identifier expected following '.', not 'version'

reply Pedro Lopes <pedrolopes gmx.com> writes:
Hello,
whenever I try to compile this chunk of code:

[code]
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if(SDL_GetWindowWMInfo(win,&info)) {
   writeln(info.subsystem);
}
[/code]
  this error shows up:
  Error: identifier expected following '.', not 'version'



BTW, i'm following the SDL official documentation (written for 
C): https://wiki.libsdl.org/SDL_GetWindowWMInfo
   Derelict SDL is fine, I have compiled SDL code before.
I Know that the word "version" is reserved for D, but how do I 
circumvent this issue?
Mar 27 2016
parent reply Mike Parker <aldacron gmail.com> writes:
On Sunday, 27 March 2016 at 07:55:10 UTC, Pedro Lopes wrote:

 BTW, i'm following the SDL official documentation (written for 
 C): https://wiki.libsdl.org/SDL_GetWindowWMInfo
   Derelict SDL is fine, I have compiled SDL code before.
 I Know that the word "version" is reserved for D, but how do I 
 circumvent this issue?
Use the source, Luke! [1] Because, as you say, version is a keyword, it will not compile when used as an identifier. As such, Derelict cannot use it, so you don't need to circumvent the issue since DerelictSDL2 already has done it for you. You just need to use the correct identifier: SDL_VERSION(&info.version_); When using Derelict, in any circumstance where you run into an identifier from a C library that is the same as a D keyword, just append an underscore to it. It's possible there may be remnants of older versions of Derelict where I didn't adhere to that pattern. If you ever encounter such, please file an issue. I want to be consistent with this. [1] https://github.com/DerelictOrg/DerelictSDL2/blob/master/source/derelict/sdl2/types.d#L2069
Mar 27 2016
next sibling parent Mike Parker <aldacron gmail.com> writes:
On Sunday, 27 March 2016 at 08:52:11 UTC, Mike Parker wrote:

 When using Derelict,
BTW, I should caution that the Sys_WM stuff in Derelict may be buggy. If you run into any odd behavior, feel free to blame it on Derelict (as long as you report it!).
Mar 27 2016
prev sibling parent Pedro Lopes <pedrolopes gmx.com> writes:
Thanks!
Mar 27 2016