www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - version assignment and module scope

reply "dcrepid" <dcrepid none.com> writes:
I'm a bit baffled why using something like this doesn't get 
recognized by imported modules:

version = Unicode;

I use this to try and alter the way the win32 API headers resolve 
certain symbols, but currently the only way to force that version 
symbol to be recognized correctly is to define it on the compiler 
command-line.

Is there some alternative to doing this?  I thought this was one 
way to emulate the C "#define" type of conditional compilation, 
but it appears that anything outside of the current module is 
unaffected by version assignments like the above.

Could this be considered a defect of design? Thanks!
Sep 15 2014
parent reply ketmar via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
On Mon, 15 Sep 2014 21:26:27 +0000
dcrepid via Digitalmars-d-learn <digitalmars-d-learn puremagic.com>
wrote:

 Could this be considered a defect of design?
no. it works the way it's intended to work. given that order of module imports is not defined (i.e. reordering imports should not affect resulting code), making 'version=3D' propagating to other modules will create disasterous side effects, even weirder than C macro abusing. "#define" is BAD, but in C you can at least control order of imports. in D you can't, so making 'version=3D' affect other modules will turn everything to hellish nightmare.
Sep 15 2014
parent "dcrepid" <dcrepid none.com> writes:
 no. it works the way it's intended to work. given that order of 
 module
 imports is not defined (i.e. reordering imports should not 
 affect
 resulting code), making 'version=' propagating to other modules 
 will
 create disasterous side effects, even weirder than C macro 
 abusing.
Okay, thanks for the explanation. I hadn't considered that putting a version assignment between imports, but I see how that can become an issue.
Sep 15 2014