GCC 3.4.3 and GCC 4.1.2

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

  1. ashnin

    ashnin Guest

    Hi,

    Please clarify my doubt.

    My source dir contains combination of C and C++ files
    If I compile it using gcc 3.4.3 version, it works fine with some easy
    warnings which I can clear.

    But if I compile it using gcc 4.1.2 it throws a warning for each .cpp
    file I compile, which I could not clear

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

    What is the difference between both the compilation? Why is it
    throwing this warning when using gcc 4.1.2? How to avoid this? Is this
    anything to do with the specs file?

    Regards
    ashnin
     
    ashnin, Jul 7, 2008
    #1
    1. Advertisements

  2. ashnin a écrit :
    > Please clarify my doubt.


    I thought the answer you got earlier was clear enough.

    > My source dir contains combination of C and C++ files
    > If I compile it using gcc 3.4.3 version, it works fine with some easy
    > warnings which I can clear.
    >
    > But if I compile it using gcc 4.1.2 it throws a warning for each .cpp
    > file I compile, which I could not clear
    >
    > "cc1plus: warning: command line option "-Wdeclaration-after-statement"
    > is valid for C/ObjC but not for C++"
    >
    > What is the difference between both the compilation? Why is it
    > throwing this warning when using gcc 4.1.2?


    I guess that gcc 3.4.3 silently disabled this warning in the case of C++
    file while 4.1.2 issues a warning.

    > How to avoid this?


    Remove -Wdeclaration-after-statement from the compilation option in your
    build system for c++ files.

    > Is this anything to do with the specs file?


    I guess someone considered that declarations-mixed-with-execution is bad
    style. If you are using Makefile, hunt for it with a good grep.

    --
    Michael
     
    Michael DOUBEZ, Jul 7, 2008
    #2
    1. Advertisements

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. pini
    Replies:
    2
    Views:
    1,456
    Andras Tantos
    Nov 29, 2004
  2. Replies:
    8
    Views:
    678
  3. Kevin P. Fleming

    C99 structure initialization in gcc-2.95.3 vs gcc-3.3.1

    Kevin P. Fleming, Nov 6, 2003, in forum: C Programming
    Replies:
    2
    Views:
    869
    Kevin P. Fleming
    Nov 6, 2003
  4. Chris McDonald

    bit-fields and permitted types (and [OT] gcc)

    Chris McDonald, Apr 18, 2005, in forum: C Programming
    Replies:
    1
    Views:
    771
    Eric Sosman
    Apr 18, 2005
  5. Replies:
    5
    Views:
    562
    Nathan Addy
    Sep 17, 2005
  6. kas
    Replies:
    1
    Views:
    503
    red floyd
    Apr 22, 2010
  7. Bil Kleb
    Replies:
    6
    Views:
    332
    Bil Kleb
    Sep 18, 2006
  8. Sharwan Joram
    Replies:
    4
    Views:
    934
    Sharwan Joram
    Nov 22, 2013
Loading...