[Haskell-cafe] Re: different code in different platforms
Ben Rudiak-Gould
Benjamin.Rudiak-Gould at cl.cam.ac.uk
Fri Mar 17 10:25:26 EST 2006
Neil Mitchell wrote:
>> #ifdef __WIN32__
>> (Windows code)
>> #else
>> (Linux code)
>> #endif
>
> In Yhc, we use a runtime test to check between Windows and Linux.
I think the cleanest solution is to factor the OS-specific code into
separate modules with OS-independent interfaces and names, and pull in the
appropriate implementations at compile time by changing the module search
path. That way you avoid the syntactic and semantic ugliness of cpp as well
as most of the practical problems of a runtime test.
You can also use any two or all three of these techniques together.
-- Ben
More information about the Haskell-Cafe
mailing list