9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: 李微 <leethium@163.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] USED() macro
Date: Sat, 12 Nov 2005 22:42:36 +0800	[thread overview]
Message-ID: <1131806556.7582.86.camel@localhost.localdomain> (raw)
In-Reply-To: <ee9e417a0511120517x32c84b18w1c7062bf3e298ea@mail.gmail.com>

> 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.




  reply	other threads:[~2005-11-12 14:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-12 10:00 李微
2005-11-12 11:18 ` Charles Forsyth
2005-11-12 13:17   ` Russ Cox
2005-11-12 14:42     ` 李微 [this message]
2005-11-12 16:37       ` Russ Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1131806556.7582.86.camel@localhost.localdomain \
    --to=leethium@163.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).