News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Avoid warning "command line option "-std=c++0x" is valid for C+"

Started by camilocc, September 13, 2013, 01:14:41 PM

Previous topic - Next topic

camilocc

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
[url="https://ca2.software/"]https://ca2.software/[/url]

[url="https://twitch.tv/ca2software"]https://twitch.tv/ca2software[/url]
[url="https://mixer.com/ca2software"]https://mixer.com/ca2software[/url]
[url="https://www.youtube.com/channel/UCOb_bZgtRx3kJ_uXaEUSDzw"]https://www.youtube.com/channel/UCOb_bZgtRx3kJ_uXaEUSDzw[/url]

oBFusCATed

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!]

Alpha

Quote from: oBFusCATed on September 13, 2013, 01:45:59 PM
You have to separate the c and c++ files in two targets or two projects.
Alternatively, you could use a trunk/nightly build.

oBFusCATed

(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!]

Alpha

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

Alpha

Although, reading back through the code now,
Code (sdk/compilercommandgenorator.cpp:365) Select

    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.

oBFusCATed

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!]

Alpha

Quote from: 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)?
Yes.

Quote from: oBFusCATed on September 13, 2013, 04:39:07 PM
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.