6

I wonder why on MacOSX the macro __unix__ is not defined.

Isn't MacOSX a BSD UNIX derivative?

If I define the __unix__ macro in my code, could I have some issues?

In general, when checking the current platform, I prefer to do something like:

#ifdef __unix__
...
#endif

instead of:

#if defined(__unix__) || defined(__APPLE__) || defined(__linux__) || defined(BSD) ...
...
#endif

Could the best option be to define my own macro in a single place? E.g.:

#if defined(__unix__) || defined(__APPLE__) || defined(__linux__) || defined(BSD) ...
#define UNIX_
#endif
Brian Tompsett - 汤莱恩
  • 5,438
  • 68
  • 55
  • 126
Pietro
  • 11,309
  • 24
  • 88
  • 179

1 Answers1

4

POSIX requires _POSIX_VERSION to be defined in <unistd.h> (also accessible via sysconf(_SC_VERSION)), so try that.

ninjalj
  • 41,040
  • 9
  • 101
  • 143
  • Ok, but before including I have to check I am on a POSIX system, otherwise that file will not be available. And should not be a small file to include... – Pietro Oct 28 '11 at 23:59