# Is there a BSD Predefined Macros for GCC



## ivand58 (Oct 19, 2010)

Hello

Is there a BSD Predefined Macros for GCC? I need to recognize the OS - Linux or Unix (FreeBSD).


----------



## luna (Oct 20, 2010)

Like the following?


```
$ fgrep builtin_define /usr/src/contrib/gcc/config/freebsd-spec.h
        builtin_define_with_int_value ("__FreeBSD__", FBSD_MAJOR);     \
        builtin_define_std ("unix");                                   \
        builtin_define_std ("__unix__");                               \
        builtin_define ("__KPRINTF_ATTRIBUTE__");                      \
        builtin_define_with_int_value ("__FreeBSD_cc_version", FBSD_CC_VER); \
```


----------



## luna (Oct 20, 2010)

Also, you can grep their current value from
`$ cc -dM -E -</dev/null`


----------

