Author Topic: How To Disable Specific Warnings?  (Read 18617 times)

Iyonesco

  • Guest
How To Disable Specific Warnings?
« on: August 01, 2009, 08:57:36 pm »
I recently started using Code::Blocks having only ever used Visual Studio.  It works well but I'm having a problem with an API I use is generating a lot of "enumeration value XXXX not handled in switch" warnings and I can't find out how to disable them.

In Visual Studio each warning had a number and you could enter the number in the Project Settings "Disable Specific Warnings" box.  Is there something similar in Code::Blocks that will allow me to disable this warning?

Thanks for any help you can offer.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: How To Disable Specific Warnings?
« Reply #1 on: August 01, 2009, 10:57:00 pm »
Yes, the specific way differs for each compiler and the compiler version.

Add option to disable warnings to project settings

Project -> Build Options
Tab "Compiler Settings"
Check "Compiler Flags" for needed option if not found add it to "Other Options"

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Iyonesco

  • Guest
Re: How To Disable Specific Warnings?
« Reply #2 on: August 02, 2009, 02:02:57 am »
Thanks for the reply.  Sorry, I should have said I was using the GNU GCC Compiler.

I switched to standard compiler wanrings (-W) instad of all compiler warnings (-Wall).  That got rid of most of them but I'm still getting a few warnings related to wxWidets.  I don't want to turn all warnings off so I suppose I'll just have to put up with them. 

Thanks again for the help.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: How To Disable Specific Warnings?
« Reply #3 on: August 02, 2009, 10:45:08 am »
In general you should fix your code, so it does not generate warnings.

And of course you should read the manual for your compiler(-version) to switch off (or on) special features to avoid warnings.

For gcc you find the documetation online at: http://gcc.gnu.org/onlinedocs/ .

Offline Archibald

  • Single posting newcomer
  • *
  • Posts: 3
Re: How To Disable Specific Warnings?
« Reply #4 on: August 11, 2016, 12:55:12 pm »
Is this working in 16.01?

I have tried to add "-Wunused-variable" but I can't make it to work... Had no such problems in previous version.

What exacly I did:
1) Settings/Compiler/Compiler Flags and then added "New flag".
2) Also tried the old route Settings/Compiler/Other compiler options and then added it manually as: -Wunused-variable
None have any effect...


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: How To Disable Specific Warnings?
« Reply #5 on: August 11, 2016, 05:55:23 pm »
Code::Blocks is NOT a compiler!
We have no idea what compiler you are using!
We can NOT help you when you give very incomplete information!

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Please also read this site rules. http://forums.codeblocks.org/index.php/topic,9996.0.html

Tim S.

Is this working in 16.01?

I have tried to add "-Wunused-variable" but I can't make it to work... Had no such problems in previous version.

What exacly I did:
1) Settings/Compiler/Compiler Flags and then added "New flag".
2) Also tried the old route Settings/Compiler/Other compiler options and then added it manually as: -Wunused-variable
None have any effect...
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline raynebc

  • Almost regular
  • **
  • Posts: 217
Re: How To Disable Specific Warnings?
« Reply #6 on: August 11, 2016, 07:38:58 pm »
I use compiler flags (for MinGW) in my Codeblocks project and it seems to work perfectly fine as of the latest nightly release.  The Codeblocks feature itself is functioning as expected.

Offline Archibald

  • Single posting newcomer
  • *
  • Posts: 3
Re: How To Disable Specific Warnings?
« Reply #7 on: August 12, 2016, 08:53:18 am »
I'm using MinGW, the one which comes with the standard package. I would not ask if I were using some other compiler. That's why I find it odd that I can't make it to work since I have used only default setup... Any clues what could be the problem? Or do I set those flags incorrectly somehow? Any tips?

EDIT: I managed to make it work by adding those flags to "Other Settings" instead of "Compiler Settings/Other compiler options". Is that the place where I should have put those in the first place?

EDIT2: Tested it several times and also adding flags (via the menu "New flag") does not work while adding the same flag via "Other Settings" works perfectly. Using the existing predefined flags works as intended, just adding new ones.
« Last Edit: August 12, 2016, 09:36:45 am by Archibald »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How To Disable Specific Warnings?
« Reply #8 on: August 12, 2016, 11:10:19 am »
1)
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
we can't really help if you don't provide information on what is not working....

2) The right place to add your compiler variables is
Project->Build options
make sure you have selected the right target on the right tree control. If you want to apply the settings for all targets then the top most entry (aka project name) has to be selected
then go to the "Compiler" tab and look if it is found in the list. If it is found check it.
If not there are two ways to add it:
2.1) you can add it by creating a new flag by "right click->new flag" provide a name, and the flag and hit "ok"
now you have to search your flag in the list and select it (mark it with a tick)
2.2) A more faster solution would be to go to the "Compiler Settings->Other compiler options" tab. There you can add the compiler switch line per line..

If something is not working and you need help, post the compiler log... we don't know what you are doing, and if you provide us with the compiler log, wen can instantly tell what is going wrong, without asking 1000 questions, and telling you 200 ways to do things... It is simply faster and not as time wasteful...

greetings

Offline Archibald

  • Single posting newcomer
  • *
  • Posts: 3
Re: How To Disable Specific Warnings?
« Reply #9 on: August 12, 2016, 11:35:23 am »
Note: I got it working already, but it works only if I enter it via Settings/Global Compiler Settings/Other Settings, all other are ignored. Just wanted to figure it out why.

That's the compiler log "warning: unused variable 'cnt' [-Wunused-variable]", pretty straightforward :) I want this warning disabled.

I have tried to do it via Settings/Compiler Settings/Compiler Flags (no effect)
I have tried to do it via Settings/Compiler Settings/Other compiler options (no effect)
I have tried to do it via Project/Build options/Compiler Flags (all trees: main, Debug, Release)  (no effect)
Only when I do it via Settings/Global Compiler Settings/Other Settings (works as intended, no more warnings of this type)

It's strange...

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: How To Disable Specific Warnings?
« Reply #10 on: August 12, 2016, 12:12:25 pm »
You must use -Wno-unused-variable (with the no- prefix) to suppress the message.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How To Disable Specific Warnings?
« Reply #11 on: August 12, 2016, 02:21:29 pm »
That's the compiler log "warning: unused variable 'cnt' [-Wunused-variable]", pretty straightforward :) I want this warning disabled.
Can you read? This is not the build log stahta01 are asking for... There is 0 information of what we need...

I have tried to do it via Project/Build options/Compiler Flags (all trees: main, Debug, Release)  (no effect)
Have you followed my steps??

Only when I do it via Settings/Global Compiler Settings/Other Settings (works as intended, no more warnings of this type)
This has absolutely nothing to do with the compiler, but how codeblocks handles the compiler output...