Is there a universal macro for any BSD system. I am currently on FreeBSD where
__FreeBSD__ is defined. It looks like on NetBSD systems
__NetBSD__ is defined. I have tried using
__BSD__ but doesn't appear to exists. 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:
PHP 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:
Quote:
Hello FreeBSD!
Hello All!
--- Edit ---
Sorry, I wasn't paying attention. I need to include [cmd]sys/param.h[/cmd].
--- Note ---
I am also posting this question to the FreeBSD forums:
https://forums.freebsd.org/viewtopic...266740#p266740