Author Topic: [Solved]c++ 11 standard argument is only added using the additional option  (Read 4939 times)

Offline Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Hello,

For my development I use:
Debian 3.16.7-ckt4-3 and code blocks 13.12.

Because I use shared_ptr in the project I need the c++11 flag to be added to the compile line.
What I found is that in the build options op the GCC compiler work different then expected.
For the general project I use the -std=c++11 option, but the compiler output there is no -std=c++11.
When I select the -std=c++11 in the release target it does add the -std=c++11.

strangely if I add the "-std=c++11" test to the other options tab twice the command added to the compiler line.
In this case I only checked the -std=c++11option in the main settings of the project.

Also when I was playing around with the settings sometimes it worked, then I restarted C::B and it did not work again.

please fix this as it has caused me a day to figure out that the IDE was my problem and not my code.
Thank you in advance.

Best regards,

Jewest
« Last Edit: February 18, 2015, 01:41:21 pm by Jewest »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: c++ 11 standard argument is only added using the additional option
« Reply #1 on: February 13, 2015, 09:44:30 am »
Hm, I'm not really sure what is the problem but is sounds like you have inappropriate value of the policy setting for you targets.
What is the value of you policy for the targets that don't 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 Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: c++ 11 standard argument is only added using the additional option
« Reply #2 on: February 13, 2015, 10:06:25 am »
In the Main project settings I specify that I want to use the C++ 11 standard.

I expect that in the compiler output I get  -std=c++11.
This  does not happen.
1]. When I select the option in the build target is does work.
2].  if I add the "-std=c++11" to the other options tab, twice the command added to the compiler line

So it looks like an internal option check is not performed correctly.

Where can I find this information: What is the value of you policy for the targets that don't work?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: c++ 11 standard argument is only added using the additional option
« Reply #3 on: February 13, 2015, 01:15:34 pm »
Project -> Build options ->  your target -> Compiler settings -> Policy (just below the tab).
(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 Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: c++ 11 standard argument is only added using the additional option
« Reply #4 on: February 17, 2015, 08:57:13 am »
Sorry I missed it.  ;)
Settings is append target options to project options.

See the screenshots this does not work.
I need to enable the C++11 in the append to make it work.
please let me know if you need more information.

[attachment deleted by admin]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: c++ 11 standard argument is only added using the additional option
« Reply #5 on: February 17, 2015, 09:36:06 am »
What does it mean it does not work?
Have you inspected the full log?
If the option is there then it works. If it is not then it doesn't.

Keep in mind that from the it is up to the installed compiler if it supports c++11 or not.
(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 Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: c++ 11 standard argument is only added using the additional option
« Reply #6 on: February 18, 2015, 11:08:21 am »
please see the attached logs

The succes log is with the additional project c++ 11 option on.
The fail is without.

search for "Release/radicentre/src/fdmsg.o"
You will see that the gcc call is missing -std=c++11 while in the log that is a succes this is added.

The major difference is that the gcc and the g++ parameters are different.
With the additional option this is corrected/ worked around.

Version 12.11 of c::b did not have this problem, here the g++ and gcc arguments are the same.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: c++ 11 standard argument is only added using the additional option
« Reply #7 on: February 18, 2015, 12:12:26 pm »
Probably the problem is that newer versions of C::B distinguish between c and c++ flags (I think).
And thus c++ flags (like std=c++11) are not passed to the C compiler.

The real problem here is that you've setup your build to use gcc (C compiler) for building c++ files.
I don't know why you do it, but most of the times it is not a good idea.
(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 Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: c++ 11 standard argument is only added using the additional option
« Reply #8 on: February 18, 2015, 01:26:44 pm »
I think I understand what the problem is .
The difference between the gcc and the g++ calls is time.
All the gcc calls are files that exist in the project file from the moment I started.
The g++ file calls are all files that have been added later on in the project.

So the assumption I make at this moment, is that C::B handling of the files has changed.
Apparently the migration from one version to the other has introduced this difference in the call.
The only question I have is how do I change this?

The file properties(compiler variable) for old files is CC while the new files are CPP.
Do I need to go through the while project file with an editor to change CC to CPP?

Offline Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: c++ 11 standard argument is only added using the additional option
« Reply #9 on: February 18, 2015, 01:40:53 pm »
Removing the CC option from the C:::B project file has solved the reported issue

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: [Solved]c++ 11 standard argument is only added using the additional option
« Reply #10 on: February 18, 2015, 04:20:38 pm »
FYI: IIRC, CB thinks any file that has an extension other than .c is a C++ file by default.

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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: [Solved]c++ 11 standard argument is only added using the additional option
« Reply #11 on: February 18, 2015, 05:15:46 pm »
FYI: IIRC, CB thinks any file that has an extension other than .c is a C++ file by default.
I don't think, so. I think there is some function that knows how to treat certain files.

@Jewest:
Do you know what tool/cb verions has been used to create your project originally?
I doubt there is a version of C::B that marks c++ files as c files in the project.
(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 Jewest

  • Multiple posting newcomer
  • *
  • Posts: 31
Re: [Solved]c++ 11 standard argument is only added using the additional option
« Reply #12 on: February 20, 2015, 10:40:07 am »
Gentlemen, you are both right.
I checked the history of my project and have to conclude that this is all on me.
The first entry of my repository starts with changing file extentions from c to cpp.
The project was written partly in c and I modified it to cpp so I could use the c++ compiler for all files.
I changed the project file with notepad as this is a lot quicker the removing all the files and adding them again.

Mistery solved, I am really sorry that I have wasted your time with this item.
« Last Edit: February 26, 2015, 01:51:58 pm by Jewest »