Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
652 views
in Technique[技术] by (71.8m points)

unix - Macro `__unix__` not defined in MacOS X

I noticed that in MacOS X (Lion), the macro __unix__ is not defined. Since MacOS has its roots in BSD UNIX, shouldn't that be the case?

Is it possible to let the compiler/preprocessor know that I want it to be considered a UNIX system?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The predefined macros site suggests using:

#if defined(unix) || defined(__unix__) || defined(__unix)
# define PREDEF_PLATFORM_UNIX
#endif

To distinguish UNIX systems. They also have warning notes about a number of compilers that don't set any of these. Depending on why you care about what the platform is you might be better off looking at configure time (in configure.ac or whatever build system you're using).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...