Click here to Skip to main content
11,930,069 members (50,966 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++
command line option "-std=c++0x" is valid for C++/ObjC++ but not for C...what's this about?
Posted 27-Sep-12 6:31am
Richard MacCutchan 27-Sep-12 11:57am
C does not support C++.
Sandeep Mewara 27-Sep-12 12:16pm
Should not this be an answer?
Richard MacCutchan 27-Sep-12 12:25pm
Probably, but I did not verify it anywhere.
Akhilesh Halageri 27-Sep-12 12:48pm
This is the program i wrote and got the warning, what in this is strictly not a part of C?
bool pity_lessOReq(char *c,char ca)
return false;
return true;

int main()
int i=0;
STACK *stack;
char q[20]={0},ch,*chP1,*chP2,*chP3;
FILE *p;
printf("ERROR, could not find the file\n");
printf("Enter a balanced infix expression\n");
else if(ch=='a'||ch=='b'||ch=='c'||ch=='x'||ch=='y'||ch=='z')
else if(ch=='*'||ch=='/'||ch=='+'||ch=='-')
chP1=(char *)malloc(sizeof(char));
printf("The PostFix expression is : %s",q);
return 0;
Richard MacCutchan 27-Sep-12 12:55pm
You told the compiler to apply std=c++0x, but this program is C not C++ so the option is not valid.
Akhilesh Halageri 27-Sep-12 12:58pm
but the extension is .c, why should that matter??
Sergey Alexandrovich Kryukov 27-Sep-12 13:03pm
Ask it yourself. C is unrelated to this option.
Akhilesh Halageri 27-Sep-12 13:05pm
thats what i mean, when its unrelated why does the compiler enforce C++ standards on a program that isn't in C++?
Sergey Alexandrovich Kryukov 27-Sep-12 13:07pm
Ask a compiler... :-)
I don't see why do you consider this unreasonable. You said that the option is not valid for C, didn't you? But why on Earth should it be valid?
Akhilesh Halageri 27-Sep-12 13:10pm
I'm not the one who said that, twas the warning given by the compiler and i just wanted to what was it about...I'm new to programming :(
Sergey Alexandrovich Kryukov 27-Sep-12 15:43pm
Being the new one does not free you form basic logic. Don't you see that the warning makes perfect sense. If not, I don't understand what are you missing...
Akhilesh Halageri 28-Sep-12 11:33am
bt isnt it the compiler's job to implement C++ standards only on C++ programs? why is tht option even made available??
Akhilesh Halageri 28-Sep-12 12:47pm
thanks for ur time sir :) I might ask few things which might seem lame since I'm a beginner plz dont mind
Richard MacCutchan 27-Sep-12 15:13pm
You are asking the compiler to enforce C++0x standards on code that is not C++; so it responds by telling you that the option is not applicable to C code. How difficult is that to understand? It's like telling your phone company that you want to apply British rules to all your phone connections.
Akhilesh Halageri 28-Sep-12 11:35am
bt isnt it the compiler's job to implement C++ standards only on C++ programs? why is tht option even made available??
Richard MacCutchan 28-Sep-12 11:54am
Because the compiler will compile C++ source code or C source code. So if you are asking it to compile pure C code you should not use options that only apply to C++. This is a standard for all C/C++ compilers and has been so for years.
Akhilesh Halageri 28-Sep-12 12:47pm
didn't know that its a standard...thanks for ur time sir :) I might ask few things which might seem lame since I'm a beginner plz dont mind
Richard MacCutchan 28-Sep-12 13:40pm
No problem. But, as a beginner it is always worth spending some time learning about the standards as well as the language etc. You can find out quite a lot on MSDN, and also on Bjarne Stroustrup's website.
Sergey Alexandrovich Kryukov 27-Sep-12 13:02pm
Absolutely right. C++0x is the obsolete name of what is called C++11:

It is not applicable to C

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Is it about gcc?
If so, gcc is a frontend for several language compilers, one being C, another C++, etc.
It's your choice to pass the appropriate command line options to the compiler.
If you compile C code, use the right command line options: C++11 (or alike) are for sure not C options.
On the other hand, you might try to compile the C code with the C++ compiler.
See also CodeBlocks, GCC: change project language c and c++?[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.151126.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100