News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

[SOLVED] How to suppress a specific warning ?

Started by R1S8K, January 14, 2021, 08:43:44 PM

Previous topic - Next topic

R1S8K

Hi,

I want to suppress a warning related to uninitialized variables. I tried to add it to the flags but didn't know how to set it.

This is my screenshot:


Tried it but didn't work. What I'm missing here ?

oBFusCATed

1. adding it globally it is not the best idea most of the times
2. use the other settings tab and just type the option you want to pass.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

R1S8K

OK, how to type it in option tab ? I tried it now but didn't work, the same warning appears.

BlueHazzard

Project->Build options->Select your project name on the left->Compiler settings->other compiler options:
Add your flags here

R1S8K

I know this route, and I added it accordingly. But didn't work.

I put the warning as is:
-Wuninitialized

Just like that, is there other thing required with the flag ?

stahta01

You need to use the correct flag for your compiler!

GCC tends to use "-Wno-flag" to disable "-Wflag"; but, that may not always be true.

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

R1S8K



these are the warnings that work on my compiler GCC, if I check a box it affects the code compilation.

But

-Wuninitialized

isn't with them. I don't know where it came from ?

oBFusCATed

Repeating the message won't increase the changes of your success.
Especially if you ignore the information given by others (in this particular case the post by Stahta01).

If you've added an option you have to rebuild your program.
If it doesn't work inspect the build log.
If the option is not there inspect the project, target and global complier options.
Make corrections and repeat.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

R1S8K

Quote from: oBFusCATed on January 15, 2021, 02:28:52 AM

If it doesn't work inspect the build log.


Thanks for informing this point, if you didn't tell me, I wouldn't know about inspecting the log result.

I actually found the included flag with the log, I don't know if it's working to suppress the warning, because I declared a variable and didn't initialize it; with and without the inclusion of this flag but didn't get the warning as before.

gcc.exe -Wall -g -Wuninitialized -w  -c F:\Programming\programming_dev\desktop_programming\C\sketches\fun_ptr_test\main.c -o obj\Debug\main.o
gcc.exe -Wall -g -Wuninitialized -w  -c F:\Programming\programming_dev\desktop_programming\C\sketches\fun_ptr_test\modules.c -o obj\Debug\modules.o
gcc.exe -Wall -g -Wuninitialized -w  -c F:\Programming\programming_dev\desktop_programming\C\sketches\fun_ptr_test\task_manager.c -o obj\Debug\task_manager.o


Anyway I learned something today about how to deal with certain flag, and there's a lot to learn too.

Thanks all :)

stahta01

FYI: Option "-w" stops all warnings and should never be used by a newbie programmer!!!!

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