LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-22-2007, 03:12 PM   #1
lamar_air
Member
 
Registered: Oct 2004
Posts: 37

Rep: Reputation: 15
Arrow Suppress a particular gcc compiler warning?


I know with gcc you can suppress certain types of warnings by using -Wno-error-errorType to suppress errors of type "errorType". But how do you suppress one specific warning. Is there a way to do this with gcc - I understand you can do it with Visual C++ by using pragma then the unique warning id number. But in gcc i don't see unique warning numbers??

Thanks in advance!
 
Old 10-22-2007, 03:15 PM   #2
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
I'm not really sure, but why would you need to suppress a warning? It's just a warning, not an error, and later on the bug that the warning is trying to warn you about may sneak into the code elsewhere. If you've blocked that warning, you won't know it until difficult to track logic errors appear.
 
Old 10-22-2007, 03:30 PM   #3
lamar_air
Member
 
Registered: Oct 2004
Posts: 37

Original Poster
Rep: Reputation: 15
I understand you're concern. The requirement is to have warning free nightly builds and the warning is coming from a 3rd party package so being able to suppress it is desireable. Can anyone give an example of how to use gcc pragmas?

Thanks!

Last edited by lamar_air; 10-22-2007 at 03:31 PM.
 
Old 10-22-2007, 03:45 PM   #4
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
Googling around, it seems that gcc doesn't like the pragma. If there's a way to do this with a pragma, they aren't telling. :-) All the sources I can find say to do it with the -Wno-something flags on the compile command. What warning is being given? Can it be covered with a -Wno flag?
 
Old 10-22-2007, 03:53 PM   #5
lamar_air
Member
 
Registered: Oct 2004
Posts: 37

Original Poster
Rep: Reputation: 15
I agree it seems they had it long ago, then decided it was bad, and now are somewhat making it more available with gcc 3.4.0. No, the -Wno-error doesn't cover it because then it'll supress all warnings of that type not just the ones for that particular class (i think..).
 
Old 10-22-2007, 04:02 PM   #6
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
Hrm, that may be the compromise you have to live with. Alternatively, you could just wrap gcc in a little awk script that just strips that warning out. After all, a warning is really nothing more than a line on the screen.
 
Old 10-23-2007, 08:17 AM   #7
lamar_air
Member
 
Registered: Oct 2004
Posts: 37

Original Poster
Rep: Reputation: 15
That is true, thanks Patrick
 
Old 10-09-2011, 02:04 AM   #8
phorgan1
LQ Newbie
 
Registered: May 2008
Posts: 9

Rep: Reputation: 0
GCC DOES have pragmas for this, here's how they work.

I wrote this white paper originally as part of a boost wiki, http://dbp-consulting.com/tutorials/...CWarnings.html It explains everything there is to know about suppressing warnings with gcc.
 
  


Reply

Tags
compiler, gcc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler warning on HP-UX 11.23 Itanium patilvidya Programming 2 04-30-2007 01:22 AM
How to suppress particular warning message? hottdogg Programming 3 03-02-2007 01:15 AM
compiler warning! kalleanka Programming 3 07-13-2006 05:42 AM
why does gcc gives warning not an error..?? arunka Programming 2 02-05-2006 01:15 AM
suppress warning messages h/w Programming 2 10-07-2003 02:56 PM


All times are GMT -5. The time now is 03:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration