9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <forsyth@terzarima.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] x11-init.c
Date: Wed, 23 Jun 2004 10:07:04 +0100	[thread overview]
Message-ID: <539b509a0687ab7f0086c14be1187539@terzarima.net> (raw)
In-Reply-To: <cbbe27$co0$1@newstree.wise.edt.ericsson.se>

[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]

gcc enables the warnings with -Wformat, but the association between
varargs function and format checking is done by the following (on FreeBSD):

int	 asprintf __P((char **, const char *, ...)) __printflike(2, 3);

where

#define	__printflike(fmtarg, firstvararg) \
	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))


it's the __attribute__ cluster that's built-in to gcc.
Linux uses different #defines but the result is similar.
hence the need for ifdefs somewhere to avoid feeding __stuff__ to other compilers.
(there are many many more __things__.)
the list of formats is also built-in to the compiler.
it doesn't look as though it can easily be extended, but i have waded
through neither code nor spent time down by the docs.

Plan 9's compilers use a pragma to allow sets of format types
and flags to be defined outside the compiler, in a way that doesn't
give other compilers heartburn,
and thus without absolutely requiring ifdefs.  to be fair, the current
implementation assumes all flags (in the current scope) have the same meaning,
and does define a handful of built-in flags such as '.' (although neither restriction
is essential); 375 lines.

[-- Attachment #2: Type: message/rfc822, Size: 2790 bytes --]

From: Bengt Kleberg <bengt.kleberg@ericsson.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] x11-init.c
Date: Wed, 23 Jun 2004 08:47:20 GMT
Message-ID: <cbbe27$co0$1@newstree.wise.edt.ericsson.se>

Scott Schwartz wrote:
...deleted
> Gcc has a way to tell the compiler to check printf like varargs functions.
> Given the impact, maybe the ports should use that, at the cost of some ifdefs.

i hope this means that gcc should get some additional flags. it would be 
unfortunate if it means that the ports should be made dependent upon gcc.


bengt

  reply	other threads:[~2004-06-23  9:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-22 22:33 Rob 'Commander' Pike
2004-06-23  1:23 ` Scott Schwartz
2004-06-23  5:02   ` Charles Forsyth
2004-06-23 10:18     ` boyd, rounin
2004-06-23  8:47   ` Bengt Kleberg
2004-06-23  9:07     ` Charles Forsyth [this message]
2004-06-23 19:05   ` William Josephson
2004-06-23 19:07 ` William Josephson

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=539b509a0687ab7f0086c14be1187539@terzarima.net \
    --to=forsyth@terzarima.net \
    --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).