Hello
I'm writing some code that I want to be portable across Posix and
Windows.
What is the recommended code convention for such type of code ?
80% of the class implementation is the same for both OS.
Should I write the following and copy past the 80%
version( Windows ) {
import core.sys.windows;
class MyInfo {...}
} else version( Posix ) {
import core.sys.posix;
class MyInfo {...}
} else {
static assert(false, "Unsupported platform");
}
or should I do it the C way with multiple embedded static if... ?
version( Windows ) {
import core.sys.windows;
} else { //Posix
import core.sys.posix;
}
class MyInfo {
...
static if(windows) {
enum Value {...}
} static else { //Posix
enum Value {...}
}
...
}