Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: camilocc on September 13, 2013, 01:14:41 pm

Title: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: camilocc 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
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: oBFusCATed 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.
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: Alpha 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.
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: oBFusCATed on September 13, 2013, 03:45:47 pm
Alternatively, you could use a trunk/nightly build.
Can you elaborate on this statement a bit?
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: Alpha 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 (http://cb.biplab.in/websvn/filedetails.php?repname=codeblocks&path=%2Ftrunk%2Fsrc%2Fplugins%2Fcompilergcc%2Fresources%2Fcompilers%2Foptions_common_sort.xml)
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: Alpha 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.
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: oBFusCATed 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! :)
Title: Re: Avoid warning "command line option "-std=c++0x" is valid for C+"
Post by: Alpha 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.