[Issue 13605] Add ability to `version` a module declaration

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Oct 24 07:41:22 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13605

hsteoh at quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh at quickfur.ath.cx

--- Comment #8 from hsteoh at quickfur.ath.cx ---
You do realize that in D, the module name must match the source filename,
right? So your proposed solution won't work.

The recommended way to achieve what you want is as follows:

----port_linux.d----
module port_linux;
... // Linux stuff here

----port_windows.d----
module port_windows;
... // Windows stuff here

----port.d----
version(linux)
    public import port_linux;
version(Windows)
    public import port_windows;

----main.d----
import port; // will pull in correct version of stuff depending on platform
void main() { ... }

--


More information about the Digitalmars-d-bugs mailing list