Date: Fri, 01 Dec 2000 15:11:21 +1100 From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: Brooks Davis <brooks@one-eyed-alien.net> Cc: audit@FreeBSD.ORG Subject: Re: gcc __attributes for format strings Message-ID: <20001201151121.J1474@gsmx07.alcatel.com.au> In-Reply-To: <20001130193600.A4439@Odin.AC.HMC.Edu>; from brooks@one-eyed-alien.net on Thu, Nov 30, 2000 at 07:36:00PM -0800 References: <20001126222048.A46809@citusc17.usc.edu> <200011271604.eARG49V29464@troutmask.apl.washington.edu> <20001201134903.H1474@gsmx07.alcatel.com.au> <20001130193600.A4439@Odin.AC.HMC.Edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2000-Nov-30 19:36:00 -0800, Brooks Davis <brooks@one-eyed-alien.net> wrote: >On Fri, Dec 01, 2000 at 01:49:03PM +1100, Peter Jeremy wrote: >> In general, gcc attributes are not directly put in the code. Rather >> there are a series of macros in <sys/cdefs.h> which map 4.4BSD >> attributes onto compiler-specific attributes. If we move to a >> different compiler, we just need to change cdefs.h > >Too bad this won't work in general. I know. The ANSI standard reserved #pragma for these sorts of compiler hints. Unfortunately, #pragma is totally useless for portable code. The GCC documentation says it best: " Some people object to the `__attribute__' feature, suggesting that ANSI C's `#pragma' should be used instead. There are two reasons for not doing this. 1. It is impossible to generate `#pragma' commands from a macro. 2. There is no telling what the same `#pragma' might mean in another compiler. These two reasons apply to almost any application that might be proposed for `#pragma'. It is basically a mistake to use `#pragma' for _anything_." > ISO should pull it's head out of it's ass and declare a standard. It needs to declare a standard that is useful and extensible. #pragma only achieves the latter but by having a null set of standard meanings and not allowing macros, it totally fails to be useful. Using magic comment strings has a fairly long history, but is similarly useless due to its inability to be used with macros. Peter To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001201151121.J1474>