Author Topic: Code::Blocks not showing warnings  (Read 15975 times)

Offline mgoyanes

  • Multiple posting newcomer
  • *
  • Posts: 14
Code::Blocks not showing warnings
« on: February 21, 2012, 07:29:27 pm »
Hi.

I'm on Win 7 64 bits and just installed codeblocks-10.05mingw-setup.exe.

In Settings->Compiler and debbuger I've set the flags -ansi -Wall and -pedantic to show me all the warnings.
If I use this code and press F9 the program runs all the way and does not show me any warnings.
On the other and, if I press Ctrl+F11 (rebuild) now, on the build message log It shows the warning I was expecting
Quote
main.c||In function 'main':|
main.c|6|warning: unused variable 'c'|
||=== Build finished: 0 errors, 1 warnings ===|


Wasn't expected that the program didn't run and show me the exact same message as when doing rebuild?

What can I do to this warnings show when I press F9?

Regards,

mgoyanes

Code
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int c;
    printf("Hello world!\n");
    return 0;
}


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Code::Blocks not showing warnings
« Reply #1 on: February 21, 2012, 07:33:52 pm »
Wasn't expected that the program didn't run and show me the exact same message as when doing rebuild?
No.

Run = Run a previously compiled program.
Build = Compile all files that have changed in their sources or new files that haven't been compiled at all.
Build + Run = Combination of above.
Re-Build = Remove all previously compiled files and re-build them all.

You'll see compiler warnings only when you compile a file.

So if you hit just run there is no build at all. If you hit build and you didn't change the source file which causes the warning you won't see it again until you either change the source code or hit re-build.

It's by design and pretty much the same for every IDE.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mgoyanes

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Code::Blocks not showing warnings
« Reply #2 on: February 21, 2012, 07:38:47 pm »
Thanks.

Made a new project with the exact same code.

As you explained, now if I pressed F9 (build and run) warning should appear? Right?
But not. Its the exact same situation. Warnings appear only with F11


Offline mgoyanes

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Code::Blocks not showing warnings
« Reply #3 on: February 21, 2012, 08:00:25 pm »
Just one more thing.

Now I realized, if for example, i change the name of my int variable and then press f9, on the build message log nothing appears (only when I press F11) but on the build log, a warning appears saying that the variable it's not used. but its extremely fast fast and then it's substituted by:

Quote
Checking for existence: G:\Miguel\LEI\3 Ano\2 Semestre\PPP\Práticas\Ficha01\testes3\bin\Debug\testes3.exe
Executing: "C:\Program Files (x86)\CodeBlocks/cb_console_runner.exe" "G:\Miguel\LEI\3 Ano\2 Semestre\PPP\Práticas\Ficha01\testes3\bin\Debug\testes3.exe"  (in G:\Miguel\LEI\3 Ano\2 Semestre\PPP\Práticas\Ficha01\testes3\.)


and cmd shows the print message

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Code::Blocks not showing warnings
« Reply #4 on: February 21, 2012, 08:59:06 pm »
If you do build and run, and build was successful, the build log will be cleared before running the app.
That's how C::B is designed.
You can go to "Settings -> Compiler and debugger -> [your compiler] -> Other settings" and check "Save build log to HTML when build is finished" and to get a more meaningful output "Always output the full commandline in the generated HTML file".

<Note_for_nightly_build_users>
    On newer revision these ooptions are on the tab "Build options"
</Note_for_nightly_build_users>

The HTML-file is generated in the same folder where the project-file is.

Or just build the project without directly running it (Ctrl+F9) .

Offline mgoyanes

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Code::Blocks not showing warnings
« Reply #5 on: February 22, 2012, 10:15:08 am »
If you do build and run, and build was successful, the build log will be cleared before running the app.
That's how C::B is designed.
You can go to "Settings -> Compiler and debugger -> [your compiler] -> Other settings" and check "Save build log to HTML when build is finished" and to get a more meaningful output "Always output the full commandline in the generated HTML file".

<Note_for_nightly_build_users>
    On newer revision these ooptions are on the tab "Build options"
</Note_for_nightly_build_users>

The HTML-file is generated in the same folder where the project-file is.

Or just build the project without directly running it (Ctrl+F9) .


Thanks