Author Topic: Can't remove option -Wall  (Read 16449 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: 13413
    • 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: 13413
    • 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: 9694
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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://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 Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
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: 13413
    • 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
<?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: 13413
    • 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: 13413
    • 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!]

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #15 on: August 23, 2010, 02:22:26 pm »
Ok. Sorry to labour the point but I'm trying to understand how to use this. I can see that the root compiler was set the GDC. I didn't see -Wall set in there but when I changed the root compiler to dmd the -Wall option appeared and I was able to remove it.

I can now understand some of the advice I was being given. It hasn't really clicked yet why I would want different compilers for different sets of files in a project or how one would build a project with mixed sources except to go through and select each target and do a build. At the moment each of my separate compilation units is a separate project set up with its correct compiler and I just need to build the workspace. This obviously isn't the way people use C::B it's just what I'm used to.

bob

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Can't remove option -Wall
« Reply #16 on: August 23, 2010, 03:07:14 pm »
C::B supports "multiple projects" in two ways:

1. Use of C::B project with multiple targets and one or more virtual targets combining them (take a look at  the Codeblocks.cbp file to see how it is done) // I've never done such project, so I don't know the exact details
2. Use of multiple C::B projects inside a C::B workspace. // I use this approach


p.s. -Wall was missing because it is a supported option for gdc
(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 #17 on: August 23, 2010, 06:13:35 pm »
I think I will stick to my normal multi-project method then. It's straight forward and I understand whats going on.

Is there any reason why the Wall option does not show up in the target under 'Other options' as its also not a valid option there but it is a set option.

Thanks for all the help. Sorry it took so long to get there.

bob

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Can't remove option -Wall
« Reply #18 on: August 23, 2010, 06:33:42 pm »
I think I will stick to my normal multi-project method then. It's straight forward and I understand whats going on.

Is there any reason why the Wall option does not show up in the target under 'Other options' as its also not a valid option there but it is a set option.

Thanks for all the help. Sorry it took so long to get there.

bob

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.
In your case you should have been able to uncheck the appropriate checkbox in the "Compiler flags" tab on project level.

Offline bobc

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Can't remove option -Wall
« Reply #19 on: August 24, 2010, 03:31:04 pm »
I'm really liking C::B now. I've had to do a lot of compiler switching to work out how best to get my C and D application built. C::B has made that a lot easier than any other IDE I know of.

bob