LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 06-29-2006, 11:56 PM   #1
Kikazaru
LQ Newbie
 
Registered: Nov 2003
Location: Chiba, Japan
Distribution: Ubuntu 10.10 AMD64
Posts: 17

Rep: Reputation: 0
Question Disable warnings with a pragma (g++)


Is it possible to disable all warnings, or indeed any warnings, using a compiler pragma that overrides -Wall?

I saw syntax for some C++ compiler (maybe not g++) that lets you disable warnings selectively by number, but I couldn't find a list of numbers for the warnings.

Thanks!
 
Old 07-01-2006, 07:25 PM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
I don't see any #pragma options that enable this effect, but you can use the GCC function attribute "unused" to accomplish the same thing. The downside is you need to set it for each function for which you want to disable warnings. The GCC Manual for version 3.3.6 mentions that it won't work for C++; the manuals for later versions do not make such a mention. Here's the relevant section in the manual [gcc.gnu.org] for the latest stable version.
 
Old 07-01-2006, 07:57 PM   #3
Kikazaru
LQ Newbie
 
Registered: Nov 2003
Location: Chiba, Japan
Distribution: Ubuntu 10.10 AMD64
Posts: 17

Original Poster
Rep: Reputation: 0
Wow, that's interesting. I didn't realize there were so many possible function attributes...

I suppose the unused attribute could work for me, but I have a few source files with hundreds of functions in them. I don't fancy dealing with them all individually.

Thanks for the suggestion.
 
Old 07-01-2006, 09:58 PM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Quote:
Originally Posted by Kikazaru
I suppose the unused attribute could work for me, but I have a few source files with hundreds of functions in them. I don't fancy dealing with them all individually.
If you want to set the attribute for all (or nearly all) of your functions in a given file, sed could probably help you there.
 
  


Reply



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
warnings on perl doronunu Programming 8 05-02-2006 07:09 AM
tar warnings early Linux - General 2 01-05-2006 08:57 PM
what are the services i can disable, also disable ads, banners in konqueror? greythorne SUSE / openSUSE 3 03-16-2005 08:30 AM
Linux equivalents for #pragma DavidW567 Programming 2 03-09-2005 01:24 PM
Pragma: no-cache workaround OhLordy Linux - Networking 1 05-09-2003 05:18 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:46 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration