Versioned extern?
Steven Schveighoffer
schveiguy at yahoo.com
Fri Jul 29 07:35:45 PDT 2011
On Sat, 23 Jul 2011 23:35:39 -0400, 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):
> ------------------------------
does this work?
private void fnImpl(...)
{
// code here
}
version(Windows)
{
extern(Windows) fn(...) {fnImpl();}
}
else
{
extern(C) fn(...) {fnImpl();}
}
-Steve
More information about the Digitalmars-d-learn
mailing list