Spencer Janssen | 21 Dec 04:16
Favicon

Re: How to use #ifdef WIN32

On Thursday 20 December 2007 18:37:15 Jim Burton wrote:
> I want to switch code on the OS but this always goes through to the #else
> (on windows or elsewhere):
>
> {-# OPTIONS -cpp #-}
> #ifdef WIN32
> main = putStrLn "hello windows"
> #else
> main = putStrLn "hello something else"
> #endif
>
> Does this depend on a Makefile setting WIN32, or should there be something
> predefined?
>
> Thanks,

If you're using Cabal, something like this should work:

    if os(win32)
        cpp-options: -DWIN32

Cheers,
Spencer Janssen

Gmane