Re: Versioned extern?
"Aleksandar Ruzicic" wrote in message news:mailman.1954.1311949602.14074.digitalmars-d-le...@puremagic.com... > >Ouh, haven't read that you don't want code to be mixed-in.. In that case.. I dunno :) It's not that I didn't want to, it's just that I was wondering if there was a better way. Fortunately, version(System) is exactly what I needed in my specific case, even if it isn't a general solution.
Re: Versioned extern?
http://d.puremagic.com/issues/show_bug.cgi?id=5739#c3
Re: Versioned extern?
On Sat, 23 Jul 2011 23:35:39 -0400, Nick Sabalausky 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): -- does this work? private void fnImpl(...) { // code here } version(Windows) { extern(Windows) fn(...) {fnImpl();} } else { extern(C) fn(...) {fnImpl();} } -Steve
Re: Versioned extern?
Ouh, haven't read that you don't want code to be mixed-in.. In that case.. I dunno :) 2011/7/29 Aleksandar Ružičić : > 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 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): >> -- >> >> >> >> >> >
Re: Versioned extern?
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 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): > -- > > > > >
Re: Versioned extern?
On Saturday, July 23, 2011 8:35:39 PM, Nick Sabalausky 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): > -- That specific pair of extern types with that specific set of versions --> extern(System)
Versioned extern?
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): --