externally imposed conditional compilation

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Fri Nov 23 03:38:21 PST 2012


Hi, D community.

I have C code (*cough* WinAPI *cough*) like:

#if FOOBAR == 1
#define SOMETHING
#elif FOOBAR > 2
#define SOMETHING
#elif FOOBAR < 5
#define SOMETHING
#endif

Which I want to translate to D.

Here are the problems I have:
1. I can't use versions because:
    1.1. The identifier version won't work because the set of values for
FOOBAR is unknown, thus cannot be enumerated as different version
identifiers.
    1.2. The number version won't work because there are tons of other
things like FOOBAR and they can't all use the version number.
2. I can't use static if because:
    2.1. I can't define FOOBAR from outside of the package this code will
be in.
    2.2. I can't include the definition of FOOBAR into the package (like
config.d) and expect it to be changed as necessary, because the package
encapsulation will be broken.

What's the best/standard way translating this to D?

-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121123/93f863a5/attachment.html>


More information about the Digitalmars-d mailing list