From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [9fans] USED() macro From: =?UTF-8?Q?=E6=9D=8E=E5=BE=AE?= To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: References: <1131789636.7582.55.camel@localhost.localdomain> <0127f0e483812bde9207dcadeb8a009f@terzarima.net> Content-Type: text/plain Date: Sat, 12 Nov 2005 22:42:36 +0800 Message-Id: <1131806556.7582.86.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: ab80118a-ead0-11e9-9d60-3106f5b1d025 > In Plan 9's C compiler, USED is known to the compiler. > It makes the compiler insert a use of the variable right > there to silence used and not set warnings. > > In the ports, it's a clumsy macro trying to have the same > effect. > > > perhaps it could use if(&x) instead of if(x) > > to cope with structures as well > > I tried this once, but then some (too smart for their > own good) compilers complain that the value is never used. Thanks. BTW, I'm trying to build plan9port on Ubuntu 5.10. Some problems encountered: 1) X headers are in /usr/include/X11 only. No 'include' in $X11, not even a link. So, $PLAN9/src/libdraw/mkwsysrules.sh could not find them; and set $WSYSTYPE to 'nowsys'. As a result nowsys-*.c get compiled, and I noticed USED() there. 2) install(1) says: > If LOCAL.config contains a line WSYS=nowsys then the system is built > without using X11. I guess it might be WSYSTYPE=nowsys? 3) 9c uses gcc, but USED() is still defined as if(x){}else{}, not the version with __attribute__ ((unused)). When I added -D__GNUC__ in 9c, it complained for redefinition. Why not #ifdef __GNUC__ # if __GNUC__ >= 3 # undef USED # define USED(x) { ulong __y __attribute__ ((unused)); __y = (ulong)(x); } # endif #endif functioning correctly? Well, after all, those are all trivial. Few people will set WSYSTYPE=nowsys.