Versioned extern?
Aleksandar Ružičić
ruzicic.aleksandar at gmail.com
Fri Jul 29 07:24:22 PDT 2011
If I'm not mistaken extern() accepts only Identifier, not expression.
I'm not really sure what's the best way to do that but I belive this
should work (haven't tested):
enum code = q{
void func() {
// do something
}
};
version (Windows) {
extern (Windows) {
mixin(code);
}
} else {
extern (C) {
mixin(code);
}
}
On Sun, Jul 24, 2011 at 5:35 AM, Nick Sabalausky <a at a.a> wrote:
> Is there a way to have a section of code be extern(C) on one OS and
> extern(Windows) on another OS, without resorting making the code in question
> a mixin?
>
> These doesn't appear to work:
>
> ------------------------------
> version(Windows)
> {
> enum callingConvention = "Windows";
> }
> else
> {
> enum callingConvention = "C";
> }
>
> extern(mixin(callingConvention ))
> {
> /+ ...code here... +/
> }
> ------------------------------
> version(Windows)
> {
> extern(Windows):
> }
> else
> {
> extern(C):
> }
>
> /+ ...code here... +/
>
> extern(D):
> ------------------------------
>
>
>
>
>
More information about the Digitalmars-d-learn
mailing list