Compiler defines for FreeBSD, was: Re: [Directoryadmin-list]compile trouble

Chuck Swiger cswiger at mac.com
Sat Apr 5 12:36:57 PST 2003


Andy Harrison wrote:
> I was wondering if any of you guys could help this guy out.  I tried to
> download and compile his app and it didn't go so smoothly.  He ask me a
> question about detecting freebsd that I couldn't answer.  Anyone know a way he
> could accomplish this?  Thanx!

"gcc -v" suggests __FreeBSD__:

[ ... ]
gcc version 2.95.4 20020320 [FreeBSD]
  /usr/libexec/cpp0 -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -Di386 
-D__FreeBSD__=4 -D__FreeBSD_cc_version=460001 -Dunix -D__i386__ 
-D__FreeBSD__=4 -D__FreeBSD_cc_version=460001 -D__unix__ -D__i386 
-D__unix -Acpu(i386) -Amachine(i386) -Asystem(unix) -Asystem(FreeBSD) 
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__ELF__ 
/tmp/a.c /tmp/ccDlMXAX.i

...although using OS-specific defines is not particularly graceful.

-Chuck



More information about the freebsd-questions mailing list