Extern/scope issue
DLearner
bmqazwsx123 at gmail.com
Sat Apr 3 11:38:52 UTC 2021
> extern(L) extern otherQualifiersIfAny variableType
> variableName; //appears to be a variable declared outside of
> the module, so at link time a .obj file will have to declare a
> variable with this symbol name or else the linker will error
> out.
> ```
> It seems that case 4 is what you desired but i do not know if
> with this module hierarchy it can/will work with dub.(it
> should.)
> With the code as is you should be able to access both variables
> from main with `testmod.xvar` and simply `xvar`.(when name
> conflicts like this occur the most local is used by default,
> otherwise use the full name which should be `testmain.xvar` in
> this case.)
I tried case 4, failed with link errors.
I am not trying to establish two variables, just exactly the same
one everywhere.
That's why the desired test output is 1,1,2,2
More information about the Digitalmars-d-learn
mailing list