version: multiple conditions

bitwise via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 13 13:57:14 PDT 2015


What is the rationale for not allowing multiple version conditions?

Example:

version(iOS || Android) {
     pthread_create(...)
}
else version(Win32) {
     CreateThread(...)
}

I wasn't able to find the conversations on this.

I heard rumors in DLearn that Walter was against this, but I'm wondering  
if the sentiment has changed at this point. Is there is any wiggle room  
for at least adding "||" so that code can be shared between platforms?


This is trivial to do in C, C++, and even C#:

#if OS_IOS || OS_ANDROID
    ...
#elif OS_WINDOWS

#endif


In Rust, there is attributes for this:

#[cfg(any(not(unix), all(target_os="macos", target_arch = "powerpc")))]
void something() {

}

I haven't yet seen a solution in D that justifies not having this feature.


Thanks,
   Bit


More information about the Digitalmars-d mailing list