Closed ghost closed 8 years ago
Yes, it's a bug.
Enums are always generated as global variables regardless of versionblock.
At rock/middle/EnumDecl.ooc : createCovers
:
slit := StructLiteral new(valuesCoverDecl getInstanceType(), elements, token)
valuesGlobal = VariableDecl new(null, name + "__values", slit, token)
valuesGlobal isGlobal = true
token module body add(valuesGlobal)
the generated cover is always global. Then global variable will be unwrapped to a global definition and a assignment, so you will see the following c codes :
#if defined(__WIN32__) || defined(__WIN64__)
lang_types__Class___load__();
#endif
issue935__TestEnum__values_t___load__();
issue935__TestEnum__values = (issue935__TestEnum__values_t) {
WAIT_OBJECT_0
}
Thanks for the explanation. We're using a simple workaround for now:
version(windows) {
include windows
TestEnum: class {
Symbol1: static extern (WAIT_OBJECT_0) Long
}
}
this won't compile on Unix as rock tries to resolve the value of Symbol1, even though everything is inside version block specific to Windows: