System.Info.os is wrong, Was Re: HDBC-ODBC compile problem

Hi,
let isWindows = "mingw" `isPrefixOf` System.Info.os
Eeeeekkkkkk!!!!! Arrrrrggggghhhhh!!!! You're relying on the fact that System.Info.os is wrong to do a conditional test. Certainly for something like WinHugs/Yhc they may have never seen the evil horrors that is mingw, and certainly don't ship with any of the mingw tools. (Of course, with Hugs and GHC this code does exactly what you want, so this does work in practice) I am hoping that Yhc will return "windows" for the answer to System.Info.os, but perhaps this issue needs exploring more deeply - maybe an enumeration for os with an other field or something... Thanks Neil

Hello Neil, Tuesday, July 18, 2006, 1:38:33 AM, you wrote:
let isWindows = "mingw" `isPrefixOf` System.Info.os
Eeeeekkkkkk!!!!! Arrrrrggggghhhhh!!!!
how i can test this more correctly? actually, code that uses Win32 package is anyway surrounded by #ifdef, so the better question would be - what is best #ifdef what guarantees catching all windows installations? currently the following is used: #if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hi,
let isWindows = "mingw" `isPrefixOf` System.Info.os
how i can test this more correctly? Unfortunately, you can't - which is my point.
#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER)
#ifdef WIN32 should pick up most things I believe, certainly when compiled with MSVC, and I think also with Mingw, but you'd need to check. Thanks Neil

Neil Mitchell wrote:
let isWindows = "mingw" `isPrefixOf` System.Info.os
Eeeeekkkkkk!!!!! Arrrrrggggghhhhh!!!!
You're relying on the fact that System.Info.os is wrong to do a conditional test.
It's not a complete accident: we did envisage that making a distinction between a compiler that produces binaries via MinGW's gcc and a hypothetical compiler that produces binaries via MS's C compiler might be important, so we made System.Info.os include that distinction. Similarly it would have the value "cygwin" for a cygwin build. Nevertheless, you could persuade me that this is less than useful if you just want to know if the OS is Windows. But then perhaps there should be some other System.Info entity with more information about the OS? Cheers, Simon

Hi,
It's not a complete accident: we did envisage that making a distinction between a compiler that produces binaries via MinGW's gcc and a hypothetical compiler that produces binaries via MS's C compiler might be important, so we made System.Info.os include that distinction.
Unfortunately, even if the compiler is made with MS's C compiler (i.e. WinHugs) it still returns mingw. Yhc binaries will also be MS C produced. My worry is that unless we fix this quickly, these compilers might need to return mingw32, so code like that which started this discussion can continue to work.
Nevertheless, you could persuade me that this is less than useful if you just want to know if the OS is Windows. But then perhaps there should be some other System.Info entity with more information about the OS?
That seems a good idea. The facts that are probably relevant about the OS are: OS Type: Windows/Posix/Linux (an enumeration?) What the os looks like if you were to abstract away the details, there aren't that many OS's which are fundamentally different in terms of how userspace should act with them. Any enumeration can have Other String as the last element, but it stops matching against "magic strings" for the most part. OS Variant: Windows XP/Fedora Core (a simple string) To get useful information for injecting into bug reports, or for working around specific issues - i.e. oh, Windows XP requires this super special behaviour, but do something else in every other case. OS Environment: mingw/cygwin/64bit/32bit Things that relate to how the binary was made, what features might possibly be available etc. This seems more related to info.compiler that info.os, but if it is useful can still be included. For inspiration for the information that is returned, looking into browser strings might be a good start. Thanks Neil

Hi,
OS Variant: Windows XP/Fedora Core (a simple string) OS Environment: mingw/cygwin/64bit/32bit
Thinking about it, it seems that the thing everyone uses this information for is to make an isWindows function, so perhaps its just easier to include isWindows :: Bool. Possibly instead of/as well as this other information. Thanks Neil
participants (3)
-
Bulat Ziganshin
-
Neil Mitchell
-
Simon Marlow