471,086 Members | 814 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

C++ Warning

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?

Jul 7 '08 #1
3 7599
ashnin wrote:
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.
--
ToMo
Jul 7 '08 #2
On Jul 7, 12:37 pm, Michael DOUBEZ <michael.dou...@free.frwrote:
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.
>>>

--
Michael
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
Jul 7 '08 #3
In article <8c**********************************@d1g2000hsg.g ooglegroups.com>,
ashnin <as*********@gmail.comwrote:
>On Jul 7, 12:37 pm, Michael DOUBEZ <michael.dou...@free.frwrote:
>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++

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.
Nobody knows from the information you gave.
We neither know what is your build system nor the command line you are
using to compile.

Typically, "make" might be used. Then you need to look for the
relevant makefile or maybe environment variable. At this point, the
question becomes not a C++ question but probably a GNU make question
and if you need more help, it would be better to ask in a GNU make
specialised newsgroup or mailing list (see: www.gnu.org for how to
find the mailing lists)

Cheers

Yannick

Jul 7 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bill Burris | last post: by
1 post views Thread by spanov | last post: by
5 posts views Thread by Peter Ritchie [C# MVP] | last post: by
5 posts views Thread by holmescn | last post: by
92 posts views Thread by Heinrich Pumpernickel | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.