Confusion over version (xxx)
Lars Ivar Igesund
larsivar at igesund.net
Fri Aug 15 01:22:44 PDT 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
More information about the Digitalmars-d-learn
mailing list