Is there a universal macro for any BSD system. __FreeBSD__ is defined and it looks like on NetBSD systems __NetBSD__ is defined. I have tried using __BSD__ but doesn't appear to exist. Is there a universal way of testing if you are using any BSD system with GCC? According to this page I should be able to use BSD, but this is not working for me.
test.c:
Output:
--- Edit ---
Sorry, I wasn't paying attention. I need to include sys/param.h.
--- Note ---
I am also posting this question to the Unix.com forums: http://www.unix.com/programming/250443-gcc-general-macro-bsd.html#post302914400
test.c:
Code:
#include <stdio.h>
int main(void) {
#if defined(unix)
printf("Hello unix!\n");
#endif
#if defined(UNIX)
printf("Hello UNIX!\n");
#endif
#if defined(__unix__)
printf("Hello __unix__!\n");
#endif
#if defined(__UNIX__)
printf("Hello __UNIX__!\n");
#endif
#if defined(__BSD__)
printf("Hello __BSD__!\n");
#endif
#if defined(BSD)
printf("Hello BSD!\n");
#endif
#if defined(__FreeBSD__)
printf("Hello FreeBSD!\n");
#endif
#if !defined(__FreeBSD__)
printf("Not Hello FreeBSD!\n");
#endif
#if defined(__NetBSD__)
printf("Hello NetBSD!\n");
#endif
#if defined(__WIN32__) || defined(__WIN64__)
printf("Hello Windows!\n");
#endif
#if defined(__LINUX__)
printf("Hello Linux!\n");
#endif
}
Output:
Hello unix!
Hello __unix__!
Hello FreeBSD!
--- Edit ---
Sorry, I wasn't paying attention. I need to include sys/param.h.
--- Note ---
I am also posting this question to the Unix.com forums: http://www.unix.com/programming/250443-gcc-general-macro-bsd.html#post302914400