https://issues.dlang.org/show_bug.cgi?id=13605
Ketmar Dark <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Ketmar Dark <[email protected]> --- what to do with this code: version(Posix) module mod; int n; should it be rejected, should compiler build default module name (as it does now), or something else? 'version' is not '#ifdef', and it's bad suited for such usage. i suggest to use wrapper module and platform-specific modules. like this: === port.d === module port; version(Posix) public import port.posix; else version(Win32) public import port.win32; else version(Win64) public import port.win64; else static assert(0, "no porting was done for this platform!"); === port/posix.d === module port.posix; version(Posix): // posix code follows === port/win32.d === module port.win32; version(Win32): // win32 code follows and so on. this way you can build your code on all platforms passing all source files to build command, yet you get only that code which is relevant to your destination platform. and you can write all platform-independend code in "port.d". note "public import" here, which makes platform-specific imports public, so you can define function `foo()` for each platform independently. note: i suggest to avoid such public imports, though. it's better to write wrappers in "port.d" which calls platform-specific `foo()`. there are some problems with public imports with renamings and such. --
