Issue 11666: "Separation of platforms", and module declaration
Mike via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 8 23:00:03 PDT 2014
On Saturday, 9 August 2014 at 05:38:33 UTC, H. S. Teoh via
Digitalmars-d wrote:
> On Sat, Aug 09, 2014 at 05:08:09AM +0000, Mike via
> Digitalmars-d wrote:
>> The idea is to have the same module declaration in multiple
>> files, but
>> guarded by `version`.
>>
>> // port_linux.d
>> version (linux):
>> module port;
>>
>> // port_windows.d
>> version (Windows):
>> module port;
>>
>> Unfortunately, this fails to compile with the following error:
>> Error: Declaration expected, not 'module'
> [...]
>
> What about this:
>
> // port.d
> module port;
> version(linux)
> public import port_linux;
> version(Windows)
> public import port_windows;
>
> // port_linux.d
> ... // Linux implementation here
>
> // port_windows.d
> ... // Windows implementation here
>
Doesn't that introduce a new namespace?
More information about the Digitalmars-d
mailing list