Author Topic: [SOLVED] How to suppress a specific warning ?  (Read 7440 times)

Offline R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 23
[SOLVED] How to suppress a specific warning ?
« 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:


Tried it but didn't work. What I'm missing here ?
« Last Edit: January 15, 2021, 03:49:04 am by R1S8K »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to suppress a specific warning ?
« Reply #1 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.
(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!]

Offline R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: How to suppress a specific warning ?
« Reply #2 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.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How to suppress a specific warning ?
« Reply #3 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

Offline R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: How to suppress a specific warning ?
« Reply #4 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 ?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7666
    • My Best Post
Re: How to suppress a specific warning ?
« Reply #5 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.
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 R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: How to suppress a specific warning ?
« Reply #6 on: January 15, 2021, 01:15:28 am »


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 ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to suppress a specific warning ?
« Reply #7 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.
(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!]

Offline R1S8K

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: How to suppress a specific warning ?
« Reply #8 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 :)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7666
    • My Best Post
Re: [SOLVED] How to suppress a specific warning ?
« Reply #9 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.
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