C++ Warning

A

ashnin

Hi,

Can anyone tell me, why am I getting this warning?

cc1plus: warning: command line option "-Wdeclaration-after-statement"
is valid for C/ObjC but not for C++

(Actually Im compiling a set of C & C++ files from the same source
dir. )

What should be done to avoid this warning?
 
T

ToMo

ashnin said:
Hi,

Can anyone tell me, why am I getting this warning?

cc1plus: warning: command line option "-Wdeclaration-after-statement"
is valid for C/ObjC but not for C++

(Actually Im compiling a set of C & C++ files from the same source
dir. )

What should be done to avoid this warning?

This often happens when you have the same set of switches/options for
both C and C++ compilers. This warning obviously doesn't make sense in
C++ language, but it does for C language.
 
M

Michael DOUBEZ

ashnin a écrit :
Hi,

Can anyone tell me, why am I getting this warning?

cc1plus: warning: command line option "-Wdeclaration-after-statement"
is valid for C/ObjC but not for C++

(Actually Im compiling a set of C & C++ files from the same source
dir. )

What should be done to avoid this warning?

You should simply remove it from your build system unless you want the
old C declaration system that required variables to be declared at the
beginning of a block.

In all cases, you should remove it from the rule processing c++ files.

Looking into the man of gcc:
<<<
C-only Warning Options
[...] -Wdeclaration-after-statement [...]

-Wdeclaration-after-statement (C only)
Warn when a declaration is found after a statement in a block. This
construct, known from C ++ , was introduced with ISO C99 and is by
default allowed in GCC . It is not supported by ISO C90 and was not
supported by GCC versions before GCC 3.0.
 
A

ashnin

ashnin a écrit :
Can anyone tell me, why am I getting this warning?
cc1plus: warning: command line option "-Wdeclaration-after-statement"
is valid for C/ObjC but not for C++
(Actually Im compiling a set of C & C++ files from the same source
dir. )
What should be done to avoid this warning?

You should simply remove it from your build system unless you want the
old C declaration system that required variables to be declared at the
beginning of a block.

In all cases, you should remove it from the rule processing c++ files.

Looking into the man of gcc:
<<<
C-only Warning Options
[...] -Wdeclaration-after-statement [...]

-Wdeclaration-after-statement (C only)
Warn when a declaration is found after a statement in a block. This
construct, known from C ++ , was introduced with ISO C99 and is by
default allowed in GCC . It is not supported by ISO C90 and was not
supported by GCC versions before GCC 3.0.

Thanks. But I never included this option in command line. Then how
come it is throwing this warning?
Please tell me how to remove it from my build system.

Regards
ashnin
 
M

Michael DOUBEZ

ashnin a écrit :
ashnin a écrit :

You should simply remove it from your build system
[snip]

Thanks. But I never included this option in command line. Then how
come it is throwing this warning?
Please tell me how to remove it from my build system.

How would I know ? I think it best your look into your documentation or
ask the guy who set it up.

Please ask in a group relevant to your build system.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top