开发者

ifdef & solaris

I want to undefine variable when compiling on SunOS. Therefore, i tried to put

#ifdef SunOS
#undef FOO
#endif

but it does not work. The problem is in #ifdef sunos ? Should i declarate it, or complier do开发者_如何转开发 it by itself ?

regards S.


I don't know of any compilers for Solaris that predefine SunOS for you.

The Sun compilers list the macros they predefine in the 'cc' man page under the -D option description, including __sun and __SunOS_5_10 (for uname -r of "5.10"), but not just plain SunOS.


Your compiler will include a number of variables predefined. See your compiler documentation to find out what that list is.

If you're trying to make a piece of software buildable on multiple (unixlike) platforms, then take a look at autoconf. It has a bit of a learning curve, but pays off very handsomely in the long term.

Addition: Also, your compiler might have a way of listing the predefined macros. For example, using gcc, touch foo.h; cpp -dM foo.h produces a list of all of then, which comes to 119 with gcc on OS X. But the documentation will probably give some indication of that compiler's recommended macros for this (but autoconf remains a better technique for this in general).


There's nothing wrong with that, cpp accept that fragment just fine. What's the problem you're seeing?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜