whats the #ifdef whatever for linux?

If you only wanna make something defined under windows you use #ifdef _WIN32. What would you use for linux?
iirc it's __unix__

There's a page with tons of compiler and platform #defines. I have the link at home, but I'm at work right now =(

I'll reply later if nobody else chimes in.
ok thanks I would appreciate the list
That's the one.

Thanks Bazzy
Most Linux systems are POSIX complaint (Portable Operating System Inteface for UNIX).

They also (normally) define _POSIX_SOURCE; _POSIX_C_SOURCE >= 200112.
When using some of the latest functions from <unistd.h> or other header you may want to check the version first.

Also you could check the _XOPEN_SOURCE >= 600 macro when using the XSI (X/Open System Interface) features.
For example, before using the XSI strdup() function you may want to ensure that your implementation supports it.

Any values lower than that would probably mean compliance to outdated or older standards.

There are more macros depending on the features your implementation of UNIX/Linux supports.
The best way is to check the standard itself.

But __unix__ or __unix is good enough for basic purposes.
Last edited on
Topic archived. No new replies allowed.