Author Topic: Can't remove option -Wall  (Read 11384 times)

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Can't remove option -Wall
« on: August 20, 2010, 11:26:38 pm »
Hi

Just started to use Code::Blocks but I've hit a problem I can't seem to get past. I'm using it to build a mixed C and D application. I'm using the Digital Mars C (dmc) and D (dmd) toolchains. The C code builds fine. When I try to build D the IDE is insisting on putting -Wall on the command line which dmd does not support. There are no checkboxes set in any of the compilers and nothing in the 'Other options' tab. How on earth can I get rid of this option.

bob

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12081
    • Travis build status
Re: Can't remove option -Wall
« Reply #1 on: August 21, 2010, 11:43:07 am »
Check if you have enabled it in the root of the targets.
Also check the Settings -> Compiler & Debugger -> Compiler
(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 driftcode

  • Single posting newcomer
  • *
  • Posts: 4
Re: Can't remove option -Wall
« Reply #2 on: August 21, 2010, 05:42:02 pm »
I ran into the same problem and it confused the hell outta me too.  The problem is two-fold. 1) The IDE sets up certain flags automatically when a new project is created using the project wizards.  Namely, certain debugging, warning, and optimization settings.  2) When you attempt to change the toolset used to build a specific target, C::B attempts to "carry over" those flags (and any others currently specified), even though that usually makes no sense.

You can tell this has happened by going to:

(for C::B 10.05)
Project > Build options... > (select a build target) >
(select a compiler that is NOT the default nor the one used when project was created) >
Compiler settings tab > Other options tab

There you'll find your extraneous flags. This is much more obvious if the default compiler settings have a lot of warning flags (-Wall, -pedantic, etc).  You can test it by selecting a bunch of flags and then changing compilers.  All the new flags will be listed in the Other options tab of the newly selected compiler.

There is a very simple solution.  Separate build targets for each compiler/toolset you want to use.  I personally have 6 build targets in my test bed project.  A debug and release target using each of mingw, openwatcom, and bcc55.  You can add new targets under Project > Properties... > Build targets tab.  Unfortunately, you'll have to set up all desired flags manually so you need to know the command-line options of that compiler pretty well, but I prefer that method anyway.   To build for a specific target, just select it in the drop-down box of the Build toolbar.  Easy.  One final note, you can either have all your build targets build to the same (default) directories, or modify them in the Project > Properties... > Build targets tab to point to specific directories.



tl;dr:  Simply changing compilers in a build target is a bad way to use multiple compilers in a project.  Set up different build targets for each compiler you wish to use.
« Last Edit: August 21, 2010, 05:48:13 pm by driftcode »

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #3 on: August 21, 2010, 09:24:18 pm »
Thanks for the info. I can make it happen by changing build targets and also make it work by not doing so. This does seem like a bug to me. How hard would it be for the IDE to remove switches not valid for the compiler. After all it knows what they are. Also giving no way to turn off options which are selected automatically seems rather inflexible. Having said that I do like Code::Blocks and pleased I can continue to use it.

bob

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12081
    • Travis build status
Re: Can't remove option -Wall
« Reply #4 on: August 21, 2010, 09:55:48 pm »
C::B supports lots of compilers and would be very hard to make a conversion for the compile time options between all of them.
So, C::B just copies the to the other compiler settings and you can remove them, so if you can this is a bug and should be fixed.
Can you provide a simple hello world project demonstrating the bug?

Also I'm not seeing any version information for os and cb?
(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 MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9508
Re: Can't remove option -Wall
« Reply #5 on: August 22, 2010, 01:49:04 pm »
C::B supports lots of compilers and would be very hard to make a conversion for the compile time options between all of them.
It's not only very hard, but impossible. Because you have to keep in mind that there are not only different compilers, but also different compiler versions (MSVC6 vs. MSVC8 (.NET) for example).

If you convert to a different compiler, it's up to you to take the appropriate steps. C::B keeps the settings for your convenience, in case you switch e.g. from a GCC based compiler to another GCC based one (e.g. MinGW to GCC/ARM).

If you project needs to support a lot of compiler although you can handle this just fine with C::B you could also use something like CMake.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #6 on: August 22, 2010, 09:22:16 pm »
Maybe I can't see the obvious but this is how to reproduce the 'bug'. There may be other scenarios. Remember this was the first time I used C::B but I think this was the scenario I fell over.

C::B is version 10.05
OS Windows 7

1. Set up so that Digital Mars D toolchain is set up correctly.
2. Do not set up GDC D toolchain such that it is a invalid compiler [YOUR ANSWER IS ALREADY THERE. SEARCH THE FORUMS!] but leave it as default.
3. Create a D project and leave all the settings as are so it uses the GDC compiler.
4. Try to build (just the default 'hello world' that the wizard provides).
5. It will complain invalid toolchain.
6. Change the compiler to Digital Mars D.
7. Build the project and it will complain about -Wall.
8. In the build options for the project there is no 'Wall' so can't turn it off there.
9. Change back to GDC compiler. Option 'Wall' is turned off there.

No where as far as I can tell is this option on but yet the build still fails with -Wall.

bob

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Can't remove option -Wall
« Reply #7 on: August 22, 2010, 10:03:05 pm »
You should look into "Project -> Build options -> Compiler settings -> Other options" for th eproject and all targets.
Compiler flags that are not handled by the checkboxes in the "Compiler flags" tab should appear there.

EDIT:
I just tested it with a switch from gdc to digital mars and it was there.

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #8 on: August 22, 2010, 11:23:59 pm »
Did you follow the instructions exactly? Where exactly did you find the option.

bob

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #9 on: August 22, 2010, 11:29:37 pm »
I just tried it again and in Project>BuildOptions>Compiler>Other options there is nothing. The test project still fails the same way.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12081
    • Travis build status
Re: Can't remove option -Wall
« Reply #10 on: August 22, 2010, 11:38:32 pm »
There is a tree on the left side of the Build options dialog,
click all items in the tree and go to compiler -> other options.
If you do no find the -Wall option, please paste the content of your cbp file. (use some pastebin site or [ code ]  tags)

Edit:
See this image: http://www.sci.brooklyn.cuny.edu/~goetz/codeblocks/glut/glut-codeblocks_html_10a7db1f.png

You should click all tree items (glut_hw, debug, release), for every item goto compiler -> other options and verify that -Wall is not defined.
« Last Edit: August 22, 2010, 11:42:52 pm by oBFusCATed »
(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 bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #11 on: August 23, 2010, 12:04:12 pm »
Oh Boy, is that a confused file. The project is set up for dmd on both debug and release. The -Wall flag is not visible anywhere. If I look at the D project that is working all the 'compiler=' elements are set to dmd.

bob

Code: [Select]
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="test" />
<Option pch_mode="2" />
<Option compiler="gdc" />
<Build>
<Target title="Debug">
<Option output="bin\Debug\test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="dmd" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin\Release\test" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gdc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="hello.d" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12081
    • Travis build status
Re: Can't remove option -Wall
« Reply #12 on: August 23, 2010, 12:21:59 pm »
http://www.sci.brooklyn.cuny.edu/~goetz/codeblocks/glut/glut-codeblocks_html_10a7db1f.png

Do you see the "Policy" combobox on this image?
What it says is that the options for this target should be appended to the project options.
And in your case the project is using the GDC compiler and the -Wall option is defined there.

There are two solutions:
1. Change the policy
2. Change the project compiler to DMD

p.s. also read this: http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks
(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 bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #13 on: August 23, 2010, 01:01:54 pm »
I think I'm being really thick here.

How do I change the project compiler to dmd. If I right click my project and select 'Build Options', both Debug and Release say the compiler is 'Digital Mars D Compiler'. If I select the GDC D compiler from any of the various places (Settings, Project or right click) I still don't see the -Wall setting anywhere.

bob

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12081
    • Travis build status
Re: Can't remove option -Wall
« Reply #14 on: August 23, 2010, 01:17:30 pm »
Have you understood the tree thing I was talking about?
Click the root of the tree and change the compiler.... it is as simple as that...
(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!]