C++ Warning

Discussion in 'C++' started by ashnin, Jul 7, 2008.

  1. ashnin

    ashnin Guest

    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?
     
    ashnin, Jul 7, 2008
    #1
    1. Advertising

  2. ashnin

    ToMo Guest

    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
     
    ToMo, Jul 7, 2008
    #2
    1. Advertising

  3. 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
     
    Michael DOUBEZ, Jul 7, 2008
    #3
  4. ashnin

    ashnin Guest

    On Jul 7, 12:37 pm, Michael DOUBEZ <> wrote:
    > 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
     
    ashnin, Jul 7, 2008
    #4
  5. ashnin a écrit :
    > On Jul 7, 12:37 pm, Michael DOUBEZ <> wrote:
    >> 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


    [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.

    --
    Michael
     
    Michael DOUBEZ, Jul 7, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Treseler

    Re: Quartus warning in NUMERIC_STD.vhd

    Mike Treseler, Jul 11, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,889
    Clyde R. Shappee
    Jul 13, 2003
  2. Pete Becker
    Replies:
    0
    Views:
    1,408
    Pete Becker
    Feb 10, 2005
  3. B. Williams

    warning C4267 and warning C4996

    B. Williams, Oct 26, 2006, in forum: C++
    Replies:
    17
    Views:
    2,679
  4. WARNING! Prosoftstore.com is a SCAM! WARNING!

    , Jul 8, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    350
  5. Julian Mehnle
    Replies:
    17
    Views:
    961
    Julian Mehnle
    May 18, 2006
Loading...

Share This Page