Thread overview
SDL Error: identifier expected following '.', not 'version'
Mar 27, 2016
Pedro Lopes
Mar 27, 2016
Mike Parker
Mar 27, 2016
Mike Parker
Mar 27, 2016
Pedro Lopes
March 27, 2016
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?




March 27, 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
March 27, 2016
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!).
March 27, 2016
Thanks!