SDL Error: identifier expected following '.', not 'version'

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 27 01:52:11 PDT 2016


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


More information about the Digitalmars-d-learn mailing list