Dual CPU code

Christopher Wright dhasenan at gmail.com
Mon Feb 2 16:20:22 PST 2009


Andrei Alexandrescu wrote:
> Walter Bright wrote:
>> bearophile wrote:
>>> Walter Bright:
>>>> import std.cpuid; import sse; import nosse; ... if
>>>> (std.cpuid.sse2()) sse2.foo(); else nosse2.foo();
>>>
>>> I think that solves my problem, thank you. It's a simple solution
>>> (maybe I didn't think of it because I use bud that compiles all the
>>> program in one go).
>>>
>>> I presume that usually the D code in the sse and nosse modules is the
>>> same, it's just compiled in two different ways, so the two modules
>>> may just contain two lines of code as:
>>>
>>> module sse; mixin(import("shared_module_code.dd"));
>>
>> That's one way to do it.
>>
> 
> I must be missing something - why isn't
> 
> import shared_module_code;
> 
> good?
> 
> 
> Andrei

The shared code has to be compiled with two sets of compiler switches, 
resulting in two distinct modules with different ModuleInfo, TypeInfo, 
and so forth. You can't do that with import.



More information about the Digitalmars-d mailing list