Author Topic: -std=c++11 not working (CB12.11)  (Read 30319 times)

Offline taimou

  • Single posting newcomer
  • *
  • Posts: 2
-std=c++11 not working (CB12.11)
« on: March 22, 2013, 06:40:34 am »
Hi,
I seem to have a very strange problem with CB12.11
For some reason it won't compile with "-std=c++11" and as for the error it says that no such command can be found:
Code
-------------- Build: default in Lethal_Sp4ce_irr (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe   -std=c++11   -IC:\SDL-1.2.15\include\SDL -IC:\irrlicht-1.8\include -IC:\SDL_mixer-1.2.12  -c D:\git\lethal_sp4ce_master\build\Lethal_Sp4ce_irr\src\ls_audio.cpp -o .objs\src\ls_audio.o
cc1plus.exe: error: unrecognized command line option "-std=c++11"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
Any ideas why it's not recognizing the option?

The project compiles fine with DevC++ so no idea what's the problem here.

- taimou

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(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 taimou

  • Single posting newcomer
  • *
  • Posts: 2
Re: -std=c++11 not working (CB12.11)
« Reply #2 on: March 22, 2013, 09:03:21 am »
This is the problem: http://wiki.codeblocks.org/index.php?title=FAQ-General#Q:_What_Code::Blocks_is_not.3F
Yes CB is not a compiler, however DevC++ also uses Mingw32-gcc as the compiler and as I said before the project compiles fine using DevC++ as the IDE.
So one could assume that CB is doing something wrong in directing the -std command to Mingw32-gcc.
Of course I can be completely wrong in this matter too, but then I'm baffled as to what could cause this problem.

//EDIT
Well I managed to fix the problem by changing the compiler CB uses to the one DevC++ uses.
Apparently there was some difference in the compiler versions then, or somesuch.
« Last Edit: March 22, 2013, 09:31:18 am by taimou »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: -std=c++11 not working (CB12.11)
« Reply #3 on: March 22, 2013, 09:49:26 am »
Which compiler have you used with C::B ?
TDM's MinGW shipped with C::B 12.11 (gcc 4.7.1) works fine with this option..

chaoticbob

  • Guest
Re: -std=c++11 not working (CB12.11)
« Reply #4 on: April 19, 2013, 11:49:07 pm »
Hi,

I know this is and old topic, but I wanted to post this in case someone runs across the same problem.

I ran into the same problem as the OP. Turned out it was exactly what I had suspected. I have several different version of MingW installed on my system. Apparently C::B is very good at finding these different versions. The version that it defaulted me to was my GNUstep MingW using GCC 4.6.1. I just changed the Compiler's installation directory in Settings->Compiler to C:\Program Files (x86)\CodeBlocks\MinGW and it fixed the problem. Obviously, this applies to GNU GCC Compiler on the drop down.

Hope it helps and happy coding. ;D

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: -std=c++11 not working (CB12.11)
« Reply #5 on: April 21, 2013, 07:01:25 pm »
Not directly related but I think cb doesn't like the '=' sign in 'project->build options->compiler settings->other options'. When I try to enter '-std=c++11' on a newline, it doesn't save nor use that setting. If I add it to another line like '-fexceptions -std=c++11' (all in one line), it works but I don't think that's the intended syntax here. And lastly if I manually edit the project file and add a new entry for '-std=c++11' it works but it's still not shown in 'project->build options->compiler settings->other options' even though it works. Am I missing something here or is it the '='?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: -std=c++11 not working (CB12.11)
« Reply #6 on: April 21, 2013, 07:13:25 pm »
It should go (automatically) into "Compiler flags".

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: -std=c++11 not working (CB12.11)
« Reply #7 on: April 21, 2013, 08:36:03 pm »
It should go (automatically) into "Compiler flags".

I checked but it didn't go into compiler flags too.

Win7 x64 cb12.11

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: -std=c++11 not working (CB12.11)
« Reply #8 on: April 21, 2013, 08:59:31 pm »
It should go (automatically) into "Compiler flags".

That does NOT work on Windows 7 32 Bit using 12.11 or self built SVN 8991.

What it does is remove from other options any thing that can be used in "Compiler flags" flags section.

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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: -std=c++11 not working (CB12.11)
« Reply #9 on: April 22, 2013, 12:12:01 am »
Is there a bug here that needs solving?  Or is this just a configuration problem?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: -std=c++11 not working (CB12.11)
« Reply #10 on: April 22, 2013, 03:23:51 am »
Is there a bug here that needs solving?  Or is this just a configuration problem?

It has always worked this way for me; no idea what configuration setting to check.
Does it work for you on Windows?

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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: -std=c++11 not working (CB12.11)
« Reply #11 on: April 22, 2013, 08:39:07 am »
Is there a bug here that needs solving?  Or is this just a configuration problem?

'-std=c++11' entry isn't saved in 'other options' nor it goes into 'compiler flags' and in the end it's not inserted into the resulting command string so I think that's not the intended behavior.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: -std=c++11 not working (CB12.11)
« Reply #12 on: April 22, 2013, 03:03:14 pm »
It should go (automatically) into "Compiler flags".
Are you sure? IMHO the philosophy is/was as follows:

If a user provided a compiler flag that is present in the checkable list of compiler switches to "other options", then we are in trouble: Checkable list defines the switch as "off", other options as "on". In that case the checkable compiler switches over-rule the other options.

So to make it simple: Never put options that are available in the checkable list of compiler switches (the check-boxes) into other options. This is by design.
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 osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: -std=c++11 not working (CB12.11)
« Reply #13 on: April 22, 2013, 08:33:44 pm »
It should go (automatically) into "Compiler flags".
Are you sure? IMHO the philosophy is/was as follows:

If a user provided a compiler flag that is present in the checkable list of compiler switches to "other options", then we are in trouble: Checkable list defines the switch as "off", other options as "on". In that case the checkable compiler switches over-rule the other options.

So to make it simple: Never put options that are available in the checkable list of compiler switches (the check-boxes) into other options. This is by design.

I'm using CB for at least two years now and never noticed [1] this 'feature'. If CB silently removes '-Wall' from 'other options' and does not turn on the checkable switch at the same time, it's definitely a bug by design!
What if '-fexceptions' becomes a checkable switch some day?

@ devs: please never modify user-specified values silently, ask for it beforehand ;D

- osdt

[1] most likely because I use one line for related options ... '-Wall -Wextra ...'
« Last Edit: April 22, 2013, 08:47:13 pm by osdt »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: -std=c++11 not working (CB12.11)
« Reply #14 on: April 22, 2013, 09:34:47 pm »
If CB silently removes '-Wall' from 'other options' and does not turn on the checkable switch at the same time, it's definitely a bug by design!

What if '-fexceptions' becomes a checkable switch some day?
No problem: At runtime, when you load a project file its managed correctly as the options are being sorted into the appropriate settings. So, if we decide to change an option (i.e. move it to "default") its no problem after you updated C::B and re-opening the project file.

In a single run, however, there is no way to find out what you mean when you tell the compiler on one setting page to enable and on the other to disable an option. What ever magic we do here is wrong in 50% of the cases. How would you decide in such a case?

Thus we decided to for for it the way it is now. In addition its more intuitive as most user search the default options in the first place.

The only fail-save way I see is to disable the check-boxes completely and force the user to enter all these flags on one page only. Hence especially newbies will cry then and never learn what a compiler can do for you. So in the end: Its not an option.
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 osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: -std=c++11 not working (CB12.11)
« Reply #15 on: April 22, 2013, 10:44:32 pm »
No problem: At runtime, when you load a project file its managed correctly as the options are being sorted into the appropriate settings. So, if we decide to change an option (i.e. move it to "default") its no problem after you updated C::B and re-opening the project file.
With the current (magic) implementation, I'm not sure what will happen ;)

In a single run, however, there is no way to find out what you mean when you tell the compiler on one setting page to enable and on the other to disable an option.
It's easy to find out what I mean by '-Wall' ... I want to see the string '-Wall' in the compiler's command line, nothing else. If CB removes the option from 'other options', I don't have explicitly turned off the checkable switch, it's off by default.

... What ever magic we do here is wrong in 50% of the cases. How would you decide in such a case?
The best decision would be: do no magic at all if you can't be sure that it's ok to do so, serious.

If you want to provide the feature of "automatically convert 'other options' to switches", ask the user beforehand. But never do it silently. As you said: your magic will be wrong in 50% of the cases. In My case likely to 100% ;D

- osdt

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: -std=c++11 not working (CB12.11)
« Reply #16 on: April 22, 2013, 10:52:09 pm »
If you want to provide the feature of "automatically convert 'other options' to switches", ask the user beforehand. But never do it silently. As you said: your magic will be wrong in 50% of the cases. In My case likely to 100% ;D
Hm, post the exact steps to show your problem.

As far as I know and seen this in action: If you type -Wall in other options and the compiler has a switch for -Wall, -Wall will be removed from other options and the switch will be enabled. This means that the command used for compilation won't change.

Do you see something else?
(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 stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: -std=c++11 not working (CB12.11)
« Reply #17 on: April 23, 2013, 03:20:02 am »
If you want to provide the feature of "automatically convert 'other options' to switches", ask the user beforehand. But never do it silently. As you said: your magic will be wrong in 50% of the cases. In My case likely to 100% ;D
Hm, post the exact steps to show your problem.

As far as I know and seen this in action: If you type -Wall in other options and the compiler has a switch for -Wall, -Wall will be removed from other options and the switch will be enabled. This means that the command used for compilation won't change.

Do you see something else?

Yes, using 12.11 on Windows it just removes the project other option; it does NOT set "-Wall" in the compiler options.

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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: -std=c++11 not working (CB12.11)
« Reply #18 on: April 23, 2013, 03:47:42 am »
Untested:
Code
Index: src/plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- src/plugins/compilergcc/compileroptionsdlg.cpp (revision 9000)
+++ src/plugins/compilergcc/compileroptionsdlg.cpp (working copy)
@@ -912,17 +971,6 @@
                     m_LinkerOptions.Insert(copt->additionalLibs, 0);
             }
         }
-        else
-        {
-            // for disabled options, remove relative text option *and*
-            // relative linker option
-            int idx = m_CompilerOptions.Index(copt->option);
-            if (idx != wxNOT_FOUND)
-                m_CompilerOptions.RemoveAt(idx, 1);
-            idx = m_LinkerOptions.Index(copt->additionalLibs);
-            if (idx != wxNOT_FOUND)
-                m_LinkerOptions.RemoveAt(idx, 1);
-        }
     }
 
     // linker options and libs

However, what is the expected behaviour?
« Last Edit: April 23, 2013, 03:53:55 am by Alpha »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: -std=c++11 not working (CB12.11)
« Reply #19 on: April 23, 2013, 08:31:28 am »
Yes, using 12.11 on Windows it just removes the project other option; it does NOT set "-Wall" in the compiler options.
Yes, of course not - for me this is expected behaviour.

I'm afraid osdt still fails to see the full picture:
if you hit OK and "-Wall" in the checkable list is off, but you have -Wall in "other options" defined to be "on", then you tell C::B on the one hand "do not use -Wall" and on the other hand "do use -Wall".

And we do no magi here at all - we just decided that the checkable list over-rules "other options". It has been like that since the beginning and only a very few people complained. Most were happy when we told how it is working behind the scenes. So I still don't see any need for change here, sorry.
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: -std=c++11 not working (CB12.11)
« Reply #20 on: April 23, 2013, 09:08:22 am »
And we do no magi here at all - we just decided that the checkable list over-rules "other options". It has been like that since the beginning and only a very few people complained. Most were happy when we told how it is working behind the scenes. So I still don't see any need for change here, sorry.
Sorry to say it, but this is a magic and it is a bit unexpected.
I guess users (including me) think that the list compiler flags and other options are combined together using and/sum operation.
Is there a technical reason behind this behaviour or this is just a decision?
(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: -std=c++11 not working (CB12.11)
« Reply #21 on: April 23, 2013, 09:11:34 am »
I guess users (including me) think that the list compiler flags and other options are combined together using and/sum operation.
Yes - and thats how its done - using AND. "on" AND "off" equals "off". Thats how it is - no magic. 8)

Is there a technical reason behind this behaviour or this is just a decision?
You have to make a decision here.
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 scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: -std=c++11 not working (CB12.11)
« Reply #22 on: April 23, 2013, 09:32:55 am »
I'm afraid osdt still fails to see the full picture:
if you hit OK and "-Wall" in the checkable list is off, but you have -Wall in "other options" defined to be "on", then you tell C::B on the one hand "do not use -Wall" and on the other hand "do use -Wall".
I have a different case here. First of all I didn't know there was a flag for '-std=c++11' in 'compiler flags'. What I did was to read gcc documentation, decide that I need a '-std=c++11' option and add it to 'other options'. So I DIDN'T tell cb to disable '-std=c++11' in the 'compiler flags' and enable it in 'other options', it's just the consequence of cb's design. And most of the novice will just copy the required options from a website or somewhere else and paste them into the 'other compiler options' without knowing about the flags. And then what? In case they see some options are missing from the command string, maybe they will fill this as a bug, which actually isn't.

Also there is the other case. Suppose one has defined some compiler option in 'other options'. Then cb gets updated and a compiler flag is added for that very option defined in 'other options'. What will be the behavior of cb in that case?

I think both settings (compiler flags and other options) must be mixed in the resulting command or 'other options' must be automatically added to 'compiler flags' if available.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: -std=c++11 not working (CB12.11)
« Reply #23 on: April 23, 2013, 09:49:28 am »
Yes - and thats how its done - using AND. "on" AND "off" equals "off". Thats how it is - no magic. 8)
My mistake here -> I though about OR.

Could we change it? What would be the downsides, because there are plenty of examples where this decision will break things.
For example scarphin's case of a flag used in old C::B and in the new C::B version it is added to the list of flags? Would this still work?
(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: -std=c++11 not working (CB12.11)
« Reply #24 on: April 23, 2013, 11:20:58 am »
For example scarphin's case of a flag used in old C::B and in the new C::B version it is added to the list of flags? Would this still work?
What happens is: If you open a project all compiler flags are being parsed (they are a list of flags). If found in the "checkbox based" settings the checkbox is enabled and if a flag is not in that list its being put to "other options". So, what happens in this specific case of a compiler option being made "official" is that this flag is being applied in the UI, but its now in a different place - in the checklist box.

So nothing gets lost, its just being visualised differently.

I think the only feasible way of handling this would be that in case we realise a difference between the checklist based and the other options we issue a warning asking what to do. The issue here is that you can use scripting (?) but at least macros in "other options" - so its not so easy to implement! And there is no automatism that will work reliable.

But if you decide to go for such a dialog - make it an annoying dialog. Because still: The overall goal is to use the checklist based list of compiler options in the first place and in case you don't find there what you are looking for use "other options" as a last resort.

If people just "copy and paste" from the internet w/o trying to understand what they are doing I don't know if its helpful to them if we account for such laziness. Its a very bad thing to do in the end.
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 osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: -std=c++11 not working (CB12.11)
« Reply #25 on: April 23, 2013, 07:33:47 pm »
I'm afraid osdt still fails to see the full picture:
if you hit OK and "-Wall" in the checkable list is off, but you have -Wall in "other options" defined to be "on", then you tell C::B on the one hand "do not use -Wall" and on the other hand "do use -Wall".

And we do no magi here at all - we just decided that the checkable list over-rules "other options". It has been like that since the beginning and only a very few people complained. Most were happy when we told how it is working behind the scenes. So I still don't see any need for change here, sorry.
I don't think so. But I get your point: "checkable compiler switches over-rule the other options" generally!
You forget completly that the user don't have switched some option off, its off by default. So it's not the user's intention to switch it off, right? Nobody will turn '-Wall' off explicitly and then add '-Wall' to 'other options'. Would make no sense, right?

I have a different case here. First of all I didn't know there was a flag for '-std=c++11' in 'compiler flags'. What I did was to read gcc documentation, decide that I need a '-std=c++11' option and add it to 'other options'. So I DIDN'T tell cb to disable '-std=c++11' in the 'compiler flags ...

@MortenMacFly: What was the intention by adding '-std=c++11' to 'other options'? Think about it, please!

As I've stated earlier: If '-fexceptions' becomes a switch some day, CB will silently remove it from 'other options' the first time the user modfies the project's build-options.

- osdt
« Last Edit: April 23, 2013, 07:41:19 pm by osdt »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: -std=c++11 not working (CB12.11)
« Reply #26 on: April 23, 2013, 08:29:02 pm »
As I've stated earlier: If '-fexceptions' becomes a switch some day, CB will silently remove it from 'other options' the first time the user modfies the project's build-options.
That is plain wrong, as I mentioned already. Nothing will get lost it will work as expected.
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 osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: -std=c++11 not working (CB12.11)
« Reply #27 on: April 24, 2013, 01:12:22 am »
If '-fexceptions' becomes a switch some day, CB will silently remove it from 'other options' the first time the user modfies the project's build-options.
That is plain wrong, as I mentioned already. Nothing will get lost it will work as expected.
You are right, my apologies for that!

I was of the opinion that 'Other options' are stored separately and then handled exactly as in the GUI (remove -fexceptions without to turn the switch on). But thats clearly not the case.

- osdt
« Last Edit: April 24, 2013, 01:56:24 am by osdt »

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: -std=c++11 not working (CB12.11)
« Reply #28 on: April 24, 2013, 03:26:22 am »
I think the only feasible way of handling this would be that in case we realise a difference between the checklist based and the other options we issue a warning asking what to do.
Just display a warning "-Wall has been removed\nUse the checklist instead".

The issue here is that you can use scripting (?) but at least macros in "other options" - so its not so easy to implement! And there is no automatism that will work reliable.
Scripts and macros are not recognized by the current implementation. It compares each line with avaiable switches. ('$WALL' and '-Wall -Wextra' works as expected ;) )

- osdt
« Last Edit: April 24, 2013, 03:29:42 am by osdt »

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: -std=c++11 not working (CB12.11)
« Reply #29 on: April 24, 2013, 03:45:48 am »
Free untested annoying dialog:
Code
Index: src/plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- src/plugins/compilergcc/compileroptionsdlg.cpp (revision 9000)
+++ src/plugins/compilergcc/compileroptionsdlg.cpp (working copy)
@@ -900,6 +900,8 @@
         }
     }
 
+    wxArrayString compilerOpConflicts;
+    wxArrayString linkerOpConflicts;
     for (unsigned int i = 0; i < m_Options.GetCount(); ++i)
     {
         CompOption* copt = m_Options.GetOption(i);
@@ -916,15 +918,32 @@
         {
             // for disabled options, remove relative text option *and*
             // relative linker option
-            int idx = m_CompilerOptions.Index(copt->option);
-            if (idx != wxNOT_FOUND)
-                m_CompilerOptions.RemoveAt(idx, 1);
-            idx = m_LinkerOptions.Index(copt->additionalLibs);
-            if (idx != wxNOT_FOUND)
-                m_LinkerOptions.RemoveAt(idx, 1);
+            if (m_CompilerOptions.Index(copt->option) != wxNOT_FOUND)
+                compilerOpConflicts.Add(copt->option);
+            if (m_LinkerOptions.Index(copt->additionalLibs) != wxNOT_FOUND)
+                linkerOpConflicts.Add(copt->additionalLibs);
         }
     }
 
+    if (!compilerOpConflicts.IsEmpty() || !linkerOpConflicts.IsEmpty())
+    {
+        wxString msg =   _("The compiler flags\n  ")
+                       + GetStringFromArray(compilerOpConflicts, wxT("\n  "))
+                       + GetStringFromArray(linkerOpConflicts, wxT("\n  "));
+        msg.RemoveLast(2); // remove two trailing spaces
+        msg += _("were stated in 'Other Options' but unchecked in 'Compiler Flags'.\n"
+                 "Do you want to enable these flags?");
+        AnnoyingDialog dlg(_("Enable compiler flags?"), msg,
+                           AnnoyingDialog::YES_NO, wxID_NO);
+        if (dlg.ShowModal() == wxID_NO)
+        {
+            for (size_t i = 0; i < compilerOpConflicts.GetCount(); ++i)
+                m_CompilerOptions.Remove(compilerOpConflicts[i]);
+            for (size_t i = 0; i < linkerOpConflicts.GetCount(); ++i)
+                m_LinkerOptions.Remove(linkerOpConflicts[i]);
+        }
+    }
+
     // linker options and libs
     wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
     for (int i = 0; i < (int)lstLibs->GetCount(); ++i)

Offline osdt

  • Multiple posting newcomer
  • *
  • Posts: 63
Re: -std=c++11 not working (CB12.11)
« Reply #30 on: April 24, 2013, 04:27:38 am »
Free untested annoying dialog:
Compiler error:
Code
/share/source/c/osdt/codeblocks/master/src/plugins/compilergcc/compileroptionsdlg.cpp|937|error: no matching function for call to 'AnnoyingDialog::AnnoyingDialog(const wxChar*, wxString&, AnnoyingDialog::dStyle, <anonymous enum>)'

wxART_INFORMATION (default param) added:
Code
Index: src/plugins/compilergcc/compileroptionsdlg.cpp
===================================================================
--- src/plugins/compilergcc/compileroptionsdlg.cpp (revision 9000)
+++ src/plugins/compilergcc/compileroptionsdlg.cpp (working copy)
@@ -900,6 +900,8 @@
         }
     }
 
+    wxArrayString compilerOpConflicts;
+    wxArrayString linkerOpConflicts;
     for (unsigned int i = 0; i < m_Options.GetCount(); ++i)
     {
         CompOption* copt = m_Options.GetOption(i);
@@ -916,15 +918,32 @@
         {
             // for disabled options, remove relative text option *and*
             // relative linker option
-            int idx = m_CompilerOptions.Index(copt->option);
-            if (idx != wxNOT_FOUND)
-                m_CompilerOptions.RemoveAt(idx, 1);
-            idx = m_LinkerOptions.Index(copt->additionalLibs);
-            if (idx != wxNOT_FOUND)
-                m_LinkerOptions.RemoveAt(idx, 1);
+            if (m_CompilerOptions.Index(copt->option) != wxNOT_FOUND)
+                compilerOpConflicts.Add(copt->option);
+            if (m_LinkerOptions.Index(copt->additionalLibs) != wxNOT_FOUND)
+                linkerOpConflicts.Add(copt->additionalLibs);
         }
     }
 
+    if (!compilerOpConflicts.IsEmpty() || !linkerOpConflicts.IsEmpty())
+    {
+        wxString msg =   _("The compiler flags\n  ")
+                       + GetStringFromArray(compilerOpConflicts, wxT("\n  "))
+                       + GetStringFromArray(linkerOpConflicts, wxT("\n  "));
+        msg.RemoveLast(2); // remove two trailing spaces
+        msg += _("were stated in 'Other Options' but unchecked in 'Compiler Flags'.\n"
+                 "Do you want to enable these flags?");
+        AnnoyingDialog dlg(_("Enable compiler flags?"), msg, wxART_INFORMATION,
+                           AnnoyingDialog::YES_NO, wxID_NO);
+        if (dlg.ShowModal() == wxID_NO)
+        {
+            for (size_t i = 0; i < compilerOpConflicts.GetCount(); ++i)
+                m_CompilerOptions.Remove(compilerOpConflicts[i]);
+            for (size_t i = 0; i < linkerOpConflicts.GetCount(); ++i)
+                m_LinkerOptions.Remove(linkerOpConflicts[i]);
+        }
+    }
+
     // linker options and libs
     wxListBox* lstLibs = XRCCTRL(*this, "lstLibs", wxListBox);
     for (int i = 0; i < (int)lstLibs->GetCount(); ++i)

Works as expected :)
I'll vote for wxID_YES instead of wxID_NO ;)

- osdt

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: -std=c++11 not working (CB12.11)
« Reply #31 on: May 02, 2013, 04:30:51 am »
If there are no complaints, I will commit this soon.

I'll vote for wxID_YES instead of wxID_NO ;)
It will be wxID_NO for the time being so that previous default behaviour remains consistent.  (However, this could change soon.)