[PATCH] __FreeBSD_kernel__
Robert Millan
rmh at debian.org
Sun Jul 3 10:34:34 UTC 2011
2011/7/3 Alexander Kabaev <kabaev at gmail.com>:
> I do not think this belongs in GCC at all. You should already have a
> defined symbol to identify your OS and that should be used in cases
> where it matters.
If we wanted to identify the OS as a whole, we can currently do this
with something like:
"#if defined(__FreeBSD_kernel__) && defined(__GLIBC__)"
however, in practice this never happens. What almost every check
wants is either to know about our userland APIs (hence __GLIBC__) or
to know about our kernel APIs (then __FreeBSD_kernel__).
In both cases, the check also wants to match other operating systems
(FreeBSD when it comes to kernel API checks, and GNU/{Linux,Hurd} when
it comes to userland API checks). Using macros that are shared (like
__GLIBC__) or that could potentially be shared (like
__FreeBSD_kernel__) with other operating systems maximizes the
opportunities to:
a) produce simpler checks like "#ifdef __GLIBC__" which are easier to
read and maintain.
b) collaborate with other projects by producing patches which have the
collateral effect of improving portability with other operating
systems.
--
Robert Millan
More information about the freebsd-hackers
mailing list