Open ibc opened 12 years ago
Reply in ruby-talk by Jon Forums:
From libuv's include/uv.h
header:
#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__) # include "uv-private/uv-unix.h" #else # include "uv-private/uv-win.h" #endif
To help prevent multi-platform lunacy, as I find useful macros I add them to a simple little C helper such as: https://gist.github.com/968522
Common approach is to detect OS within extconf.rb and set a #define via this workaround:
But it's also possible to detect OS during C compilation. It seems that Windows compilers (including MinGW) sets
_WIN32
and Unix compilers set__unix__
. Not tested however. And what about BSD, OSX and so?Useful info: http://en.wikipedia.org/wiki/C_preprocessor