Thread overview
Confusion over version (xxx)
Aug 15, 2008
Ken Barry
Aug 15, 2008
Ken Barry
Aug 15, 2008
Lars Ivar Igesund
Aug 15, 2008
Ken Barry
Aug 15, 2008
Ken Barry
August 15, 2008
Just learning D, working with GLFW and dmd 1.030 on WinXP. The files glfw.d, gl.d and glu.d shipped with the GLFW distribution contain the following...

version (Win32) {
    extern (Windows):
}
version (linux) {
    extern (C):
}

...which results in Symbol Undefined errors.
One of the files contains a variation...

version(Win32)
   extern(Windows):
else
   extern(C):

...which results in a syntax error on the 'else'.
I have tried all the variations I can think of, such as

version(Win32)
{
   extern(Windows):
}
else
{
   extern(C):
}

which also results in Symbol Undefined errors.
The only thing that works is...

version(Win32):

...on it's own. So I'm confused and would really appreciate it if anyone can explain this behaviour.
August 15, 2008
Sorry, line

version(Win32):

should read

extern(Windows):
August 15, 2008
Ken Barry wrote:

> Just learning D, working with GLFW and dmd 1.030 on WinXP. The files glfw.d, gl.d and glu.d shipped with the GLFW distribution contain the following...
> 
> version (Win32) {
>     extern (Windows):
> }
> version (linux) {
>     extern (C):
> }
> 
> ...which results in Symbol Undefined errors.
> One of the files contains a variation...
> 
> version(Win32)
>    extern(Windows):
> else
>    extern(C):
> 
> ...which results in a syntax error on the 'else'.
> I have tried all the variations I can think of, such as
> 
> version(Win32)
> {
>    extern(Windows):
> }
> else
> {
>    extern(C):
> }
> 
> which also results in Symbol Undefined errors.
> The only thing that works is...
> 
> version(Win32):
> 
> ...on it's own. So I'm confused and would really appreciate it if anyone can explain this behaviour.

Behaviour in D changed at some point, so if you see examples/code that don't work, it is just too old.

version (foo) {
extern(something):
}

will only be applied to that version block, and so it won't apply to the symbols following below the version blocks. Either duplicate all symbols in each version block, or use

extern (System):

symbols ...

System will then put in the correct extern depending on platform.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
August 15, 2008
Lars Ivar Igesund Wrote:

> Behaviour in D changed at some point, so if you see examples/code that don't work, it is just too old.
> 
> version (foo) {
> extern(something):
> }
> 
> will only be applied to that version block, and so it won't apply to the symbols following below the version blocks. Either duplicate all symbols in each version block, or use
> 
> extern (System):
> 
> symbols ...
> 
> System will then put in the correct extern depending on platform.
> 
> -- 
> Lars Ivar Igesund
> blog at http://larsivi.net
> DSource, #d.tango & #D: larsivi
> Dancing the Tango

Thanks Lars, extern (System): works just fine :)


August 15, 2008
Lars Ivar Igesund Wrote:

> Behaviour in D changed at some point, so if you see examples/code that don't work, it is just too old.
> 
> version (foo) {
> extern(something):
> }
> 
> will only be applied to that version block, and so it won't apply to the symbols following below the version blocks. Either duplicate all symbols in each version block, or use
> 
> extern (System):
> 
> symbols ...
> 
> System will then put in the correct extern depending on platform.
> 
> -- 
> Lars Ivar Igesund
> blog at http://larsivi.net
> DSource, #d.tango & #D: larsivi
> Dancing the Tango

Thanks Lars, extern (System): works just fine :)