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

Offline camilocc

  • Multiple posting newcomer
  • *
  • Posts: 23
    • ca2 Software Development
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: 13413
    • 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: 13413
    • 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: sdk/compilercommandgenorator.cpp:365
    wxString cFlags  = m_CFlags[target];
    wxArrayString remFlags;
    if (compExec == ceC)
        remFlags = GetArrayFromString(compiler->GetCPPOnlyFlags(), wxT(" "));
    else if (compExec == ceCPP)
        remFlags = GetArrayFromString(compiler->GetCOnlyFlags(), wxT(" "));
    if (!remFlags.IsEmpty())
    {
        wxArrayString aCflags = GetArrayFromString(cFlags, wxT(" "));
        for (size_t i = 0; i < remFlags.GetCount(); ++i)
        {
            int index = aCflags.Index(remFlags[i]);
            if (index != wxNOT_FOUND)
                aCflags.RemoveAt(index);
        }
        cFlags = GetStringFromArray(aCflags, wxT(" "), false);
    }
might be performance critical.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • 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.