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 06-30-2006, 12:56 AM   #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, 08: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, 08: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, 10: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


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

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

All times are GMT -5. The time now is 07:10 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