Author Topic: Avoid warning "command line option "-std=c++0x" is valid for C+"  (Read 14775 times)

Offline camilocc

  • Single posting newcomer
  • *
  • Posts: 8
Avoid warning "command line option "-std=c++0x" is valid for C+"
« on: September 13, 2013, 01:14:41 pm »
Hi,

I  am using Code::Blocks in CentOS, Ubuntu and openSUSE.

Some of my projects mixe C files and CPP files in the same project

Is there a way to specify -std=c++0x option only for g++ (CPP) and not gcc (CC)?

When building, I get these warnings:

warning: command line option "-std=c++0x" is valid for C++/ObjC++ but not for C

Because of the C files.

I cannot find in Google, may be there is a workaround like something like -Wno-(...) for avoiding the warning for C files  but I cannot find also...

Someone could help?

Would it be a feature request for Code::Blocks : to apply this flag only for g++?

Thank you in advance,
Camilo

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12086
    • Travis build status
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #1 on: September 13, 2013, 01:45:59 pm »
You have to separate the c and c++ files in two targets or two projects.
One of them should build a static library and the other should link it.
(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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #2 on: September 13, 2013, 03:20:58 pm »
You have to separate the c and c++ files in two targets or two projects.
Alternatively, you could use a trunk/nightly build.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12086
    • Travis build status
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #3 on: September 13, 2013, 03:45:47 pm »
Alternatively, you could use a trunk/nightly build.
Can you elaborate on this statement a bit?
(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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #4 on: September 13, 2013, 04:00:57 pm »
The merge of the XML compiler branch added the option to specify filtering of flags to a given compiler based on if it was C or C++ mode.  The predefined filter is:
src/plugins/compilergcc/resources/compilers/options_common_sort.xml

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #5 on: September 13, 2013, 04:15:05 pm »
Although, reading back through the code now,
Code: Text
  1.     wxString cFlags  = m_CFlags[target];
  2.     wxArrayString remFlags;
  3.     if (compExec == ceC)
  4.         remFlags = GetArrayFromString(compiler->GetCPPOnlyFlags(), wxT(" "));
  5.     else if (compExec == ceCPP)
  6.         remFlags = GetArrayFromString(compiler->GetCOnlyFlags(), wxT(" "));
  7.     if (!remFlags.IsEmpty())
  8.     {
  9.         wxArrayString aCflags = GetArrayFromString(cFlags, wxT(" "));
  10.         for (size_t i = 0; i < remFlags.GetCount(); ++i)
  11.         {
  12.             int index = aCflags.Index(remFlags[i]);
  13.             if (index != wxNOT_FOUND)
  14.                 aCflags.RemoveAt(index);
  15.         }
  16.         cFlags = GetStringFromArray(aCflags, wxT(" "), false);
  17.     }
  18.  
might be performance critical.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12086
    • Travis build status
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #6 on: September 13, 2013, 04:39:07 pm »
So if I understand you correctly this is a non-issue in trunk (the flag is not passed to gcc)?

Looking at it - I see that it is bloody dangerous wxArrayString based code! :)
(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 Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
« Reply #7 on: September 14, 2013, 09:36:29 pm »
So if I understand you correctly this is a non-issue in trunk (the flag is not passed to gcc)?
Yes.

Looking at it - I see that it is bloody dangerous wxArrayString based code! :)
At some point I want to rewrite this... as my time allows.