Jonathan Wakely - Re: How do I find when the diagnostic pragmas first came into gcc? (original) (raw)
This is the mail archive of the gcc-help@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
- From: Jonathan Wakely
- To: phorgan1 at yahoo dot com
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 12 Jan 2011 10:08:21 +0000
- Subject: Re: How do I find when the diagnostic pragmas first came into gcc?
- References: 4D1D9C9B.7060203@yahoo.com <4D232434.8030408@redhat.com> <4D238EA0.9080900@yahoo.com> <4D243BA5.2010903@redhat.com> <4D265E2E.7090005@yahoo.com> <4D2B7BA7.6080200@yahoo.com> <4D2B99E4.5090709@yahoo.com> <AANLkTinFgaPB7YkGzfV2JemFagEiCMUwosCcuY122Wai@mail.gmail.com> <4D2C0C58.2070507@yahoo.com> <AANLkTimsVqVP9tg9Z+sP7d68DB=Xxs4zoZojbxaPBBBv@mail.gmail.com> <4D2D01DE.2000305@yahoo.com>
On 12 January 2011 01:20, Patrick Horgan wrote:
On 01/11/2011 02:10 AM, Jonathan Wakely wrote:
I wrote this last week, which tames some of the ugliness:
#if ((GNUC * 100) + GNUC_MINOR)>= 405
define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
if ((GNUC * 100) + GNUC_MINOR)>= 406
?define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
? ? ?GCC_DIAG_PRAGMA(ignored x)
?define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
else
?define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored x)
?define GCC_DIAG_ON(x) ?GCC_DIAG_PRAGMA(warning x)
endif
#else
define GCC_DIAG_OFF(x)
define GCC_DIAG_ON(x)
#endif
This is great, and supports the use to turn warnings off wonderfully. ?From reading this I assume that 4.5 is the point at which the pragmas were able to be put at any scope instead of just file scope. ?Is this also true for
No, see my follow-up mail.
#pragma GCC system_header as well, that prior to 4.5 it had to be at file scope, but from 4.6 forward it can be at any scope?
As I said in another mail, I'm not sure if the system_header semantics have changed.
Also, can I steal, with attribution of course, GCC_DIAG_OFF/ON(x)?
Certainly.
Also is there an implementation define nesting limit to #pragma GCC diagnostic push as there is in the similar microsoft compiler #pragma warning push? ?(Their limit is about 50 I think). ?That seems like it would be plenty, but it's been hit in boost code that was doing tmp.
Also, what if there are too many pops? ?Is that an error, or ignored?
I don't know, you'll have to try.
Also did you consider making them so that you could use them like:
GCC_DIAG_OFF(sign-compare) ? if (a< ?b) { GCC_DIAG_ON(sign-compare) ? ? ? std::cout<< ?"a<b\n"; ? }
just to save the four keystrokes that would be common to all? ?Something like:
#define str(s) #s #define joinstr(x,y) str(x ## y)
#if ((GNUC * 100) + GNUC_MINOR) >= 405
define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
if ((GNUC * 100) + GNUC_MINOR) >= 406
?define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
? ? ? ? GCC_DIAG_PRAGMA(ignored joinstr(-W,x))
?define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
else
?define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored joinstr(-W,x))
?define GCC_DIAG_ON(x) ?GCC_DIAG_PRAGMA(warning joinstr(-W,x))
endif
#else
define GCC_DIAG_OFF(x)
define GCC_DIAG_ON(x)
#endif
I know it's a little silly, but I get carried away wanting the compiler to do stuff for me.
I didn't do that, as my use case is actually much simpler, but it seems like a nice improvement.
- References:
- Re: Strict Aliasing document
* From: Andrew Haley - Re: Strict Aliasing document
* From: Patrick Horgan - Re: Strict Aliasing document
* From: Andrew Haley - Re: Strict Aliasing document
* From: Patrick Horgan - How do I find when the diagnostic pragmas first came into gcc?
* From: Patrick Horgan - Re: How do I find when the diagnostic pragmas first came into gcc?
* From: Patrick Horgan - Re: How do I find when the diagnostic pragmas first came into gcc?
* From: Jonathan Wakely - Re: How do I find when the diagnostic pragmas first came into gcc?
* From: Patrick Horgan - Re: How do I find when the diagnostic pragmas first came into gcc?
* From: Jonathan Wakely - Re: How do I find when the diagnostic pragmas first came into gcc?
* From: Patrick Horgan
- Re: Strict Aliasing document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |