Click here to Skip to main content
15,911,762 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
command line option "-std=c++0x" is valid for C++/ObjC++ but not for C...what's this about?
Posted
Comments
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.
[no name] 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?
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include"stackADTs.h"
bool pity_lessOReq(char *c,char ca)
{
if((ca=='*'||ca=='/')&&(*c=='+'||*c=='-'))
return false;
else
return true;

}
int main()
{
int i=0;
STACK *stack;
char q[20]={0},ch,*chP1,*chP2,*chP3;
FILE *p;
stack=create_stack();
p=fopen("boo1.txt","w");
if(!p)
{
printf("ERROR, could not find the file\n");
exit(0);
}
printf("Enter a balanced infix expression\n");
while((ch=getchar())!=EOF)
fputc(ch,p);
fclose(p);
p=fopen("boo1.txt","r");
while((ch=fgetc(p))!=EOF)
{
if(ch=='(')
continue;
else if(ch=='a'||ch=='b'||ch=='c'||ch=='x'||ch=='y'||ch=='z')
q[i++]=ch;
else if(ch=='*'||ch=='/'||ch=='+'||ch=='-')
{
chP1=(char *)malloc(sizeof(char));
*chP1=ch;
if(!empty_stack(stack))
{
chP2=(char*)pop_stack(stack);
if(pity_lessOReq(chP2,ch))
{
push_stack(stack,chP1);
push_stack(stack,chP2);
}
else
{
push_stack(stack,chP2);
push_stack(stack,chP1);
}
}
else
push_stack(stack,chP1);
}
if(ch==')')
{
chP3=(char*)pop_stack(stack);
q[i++]=*chP3;
}
}
printf("The PostFix expression is : %s",q);
destroy_stack(stack);
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.

1 solution

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++?[^].

Cheers
Andi
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900