Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: R1S8K on January 14, 2021, 08:43:44 pm

Title: [SOLVED] How to suppress a specific warning ?
Post by: R1S8K on January 14, 2021, 08:43:44 pm
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:
(https://i.ibb.co/t2XTH53/warning-flags.png)

Tried it but didn't work. What I'm missing here ?
Title: Re: How to suppress a specific warning ?
Post by: oBFusCATed on January 14, 2021, 08:59:42 pm
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.
Title: Re: How to suppress a specific warning ?
Post by: R1S8K on January 14, 2021, 11:19:40 pm
OK, how to type it in option tab ? I tried it now but didn't work, the same warning appears.
Title: Re: How to suppress a specific warning ?
Post by: BlueHazzard on January 15, 2021, 12:17:43 am
Project->Build options->Select your project name on the left->Compiler settings->other compiler options:
Add your flags here
Title: Re: How to suppress a specific warning ?
Post by: R1S8K on January 15, 2021, 12:41:48 am
I know this route, and I added it accordingly. But didn't work.

I put the warning as is:
Code
-Wuninitialized

Just like that, is there other thing required with the flag ?
Title: Re: How to suppress a specific warning ?
Post by: stahta01 on January 15, 2021, 12:55:14 am
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.
Title: Re: How to suppress a specific warning ?
Post by: R1S8K on January 15, 2021, 01:15:28 am
(https://i.ibb.co/njjsHKy/warnings-list.png)

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

But

Code
-Wuninitialized

isn't with them. I don't know where it came from ?
Title: Re: How to suppress a specific warning ?
Post by: oBFusCATed on January 15, 2021, 02:28:52 am
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.
Title: Re: How to suppress a specific warning ?
Post by: R1S8K on January 15, 2021, 03:48:35 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.

Code
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 :)
Title: Re: [SOLVED] How to suppress a specific warning ?
Post by: stahta01 on January 15, 2021, 09:31:14 pm
FYI: Option "-w" stops all warnings and should never be used by a newbie programmer!!!!

Tim S.