Reason for ISO ; warning

Discussion in 'C Programming' started by pemo, Dec 7, 2005.

  1. pemo

    pemo Guest

    [Warning] ISO C does not allow extra ';' outside of a function

    int n;;

    int main(void)
    {
    ....
    }

    Anyone care to enlighten me as to why ISO C does not allow this, but
    apparently ANSI c99 does?

    Ta
     
    pemo, Dec 7, 2005
    #1
    1. Advertising

  2. pemo

    pete Guest

    pemo wrote:
    >
    > [Warning] ISO C does not allow extra ';' outside of a function
    >
    > int n;;


    That's an object definition,
    followed by what looks like an empty statement.

    >
    > int main(void)
    > {
    > ...
    > }
    >
    > Anyone care to enlighten me as to why ISO C does not allow this,


    Statements are only allowed inside of function definitions.

    > but apparently ANSI c99 does?


    I don't know so much about C99.

    --
    pete
     
    pete, Dec 7, 2005
    #2
    1. Advertising

  3. pemo said:

    > [Warning] ISO C does not allow extra ';' outside of a function
    >
    > int n;;
    >
    > int main(void)
    > {
    > ...
    > }
    >
    > Anyone care to enlighten me as to why ISO C does not allow this,


    It's the grammar. I presume you mean C90, because...

    > but apparently ANSI c99 does?


    ....here you mean ISO C99. ANSI didn't ratify the revised Standard until
    2000, so it's ANSI C2000 or, if you prefer, ANSI C00.

    I wasn't aware that executable code was allowed outside a function in C99.
    C&V?

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Dec 7, 2005
    #3
  4. pemo

    pete Guest

    Richard Heathfield wrote:

    > I wasn't aware that executable code was
    > allowed outside a function in C99.
    > C&V?


    External definitions of objects are executable code.

    --
    pete
     
    pete, Dec 7, 2005
    #4
  5. pemo

    pemo Guest

    "pete" <> wrote in message
    news:...
    > pemo wrote:
    >>
    >> [Warning] ISO C does not allow extra ';' outside of a function
    >>
    >> int n;;

    >
    > That's an object definition,
    > followed by what looks like an empty statement.
    >
    >>
    >> int main(void)
    >> {
    >> ...
    >> }
    >>
    >> Anyone care to enlighten me as to why ISO C does not allow this,

    >
    > Statements are only allowed inside of function definitions.


    Yes, that makes sense - ta.
     
    pemo, Dec 7, 2005
    #5
  6. pemo

    pemo Guest

    "Richard Heathfield" <> wrote in message
    news:dn6u49$437$-infra.bt.com...
    > pemo said:
    >
    >> [Warning] ISO C does not allow extra ';' outside of a function
    >>
    >> int n;;
    >>
    >> int main(void)
    >> {
    >> ...
    >> }
    >>
    >> Anyone care to enlighten me as to why ISO C does not allow this,

    >
    > It's the grammar. I presume you mean C90, because...
    >
    >> but apparently ANSI c99 does?

    >
    > ...here you mean ISO C99. ANSI didn't ratify the revised Standard until
    > 2000, so it's ANSI C2000 or, if you prefer, ANSI C00.
    >
    > I wasn't aware that executable code was allowed outside a function in C99.
    > C&V?


    Interesting!

    >>> It's the grammar. I presume you mean C90


    'I' didn't come into it Richard, the message came from gcc and appears
    with -Wall -pedantic -std=c99

    So, I assume c99 is what you're caling c00?
     
    pemo, Dec 7, 2005
    #6
  7. pemo

    Ian Malone Guest

    pemo wrote:
    > "Richard Heathfield" <> wrote in message
    > news:dn6u49$437$-infra.bt.com...
    >
    >>pemo said:
    >>


    >>
    >>>but apparently ANSI c99 does?

    ^^^^
    This bit

    >>
    >>...here you mean ISO C99. ANSI didn't ratify the revised Standard until
    >>2000, so it's ANSI C2000 or, if you prefer, ANSI C00.
    >>


    <snip>

    >
    >
    > 'I' didn't come into it Richard, the message came from gcc and appears
    > with -Wall -pedantic -std=c99
    >
    > So, I assume c99 is what you're caling c00?
    >
    >


    That gcc option means ISO C99, there is no ANSI C99, which seems to be
    what R Heathfield was getting at.

    --
    imalone
     
    Ian Malone, Dec 7, 2005
    #7
  8. pemo said:

    > the message came from gcc and appears
    > with -Wall -pedantic -std=c99


    Despite the flag name, gcc does not fully support C99.

    > So, I assume c99 is what you're caling c00?


    If you mean the ISO C Standard, it's C99. If you mean the ANSI C Standard,
    it's C00.

    1989: ANSI C (C89).
    1990: ISO C (C90) - this is effectively identical to C89, the only changes I
    know about being section number changes.
    1995: There was a minor mod to the Standard which, I believe, was adopted by
    both ISO and ANSI.
    1999: ISO C (C99).
    2000: ANSI C (C00 or C2000) - this is effectively identical to C99.

    Most people use C89 when they mean either C89 or C90, and C99 when they mean
    either C99 or C00/C2000 - despite the fact that C89 refers to the ANSI
    Standard and C99 refers to the ISO Standard.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Dec 7, 2005
    #8
  9. pemo

    pemo Guest

    "Ian Malone" <> wrote in message
    news:...
    > pemo wrote:
    >> "Richard Heathfield" <> wrote in message
    >> news:dn6u49$437$-infra.bt.com...
    >>
    >>>pemo said:
    >>>

    >
    >>>
    >>>>but apparently ANSI c99 does?

    > ^^^^
    > This bit
    >
    >>>
    >>>...here you mean ISO C99. ANSI didn't ratify the revised Standard until
    >>>2000, so it's ANSI C2000 or, if you prefer, ANSI C00.
    >>>

    >
    > <snip>
    >
    >>
    >>
    >> 'I' didn't come into it Richard, the message came from gcc and appears
    >> with -Wall -pedantic -std=c99
    >>
    >> So, I assume c99 is what you're caling c00?
    >>
    >>

    >
    > That gcc option means ISO C99, there is no ANSI C99, which seems to be
    > what R Heathfield was getting at.


    Ah, ok, so is -ansi the ANSI variant then?
     
    pemo, Dec 7, 2005
    #9
  10. In article <dn6tcf$3pi$>, pemo <> wrote:
    >Anyone care to enlighten me as to why ISO C does not allow this, but
    >apparently ANSI c99 does?


    Ignoring the question of what ANSI c99 is, what makes you think that it
    allows it?

    When GCC says that ISO C does not allow something, it probably means
    that GCC allows it as an extension, not that some ANSI C version
    allows it.

    -- Richard
     
    Richard Tobin, Dec 7, 2005
    #10
  11. In article <dn70b4$4s3$>, pemo <> wrote:
    >Ah, ok, so is -ansi the ANSI variant then?


    There isn't an "ANSI variant". ANSI standardised C in 1989. ISO
    adopted that definition in 1990. ISO produced another standard in
    1999, which (apparently) ANSI adopted in 2000. So ANSI C is the same
    as ISO C, and the versions can be referred to as C89 and C00 or C90
    and C99 depending on which standards body you prefer.

    -- Richard
     
    Richard Tobin, Dec 7, 2005
    #11
  12. Ian Malone said:

    > That gcc option means ISO C99, there is no ANSI C99, which seems to be
    > what R Heathfield was getting at.


    Sorry I wasn't clear. I was actually trying to get two points across at the
    same time, always a bad idea.

    The first point was that the C99 switch in gcc is a bit optimistic. gcc does
    not fully support the new Standard, no matter what you choose to call it.

    The second point was about what you choose to call it!, and that has now
    been explained ad nauseam.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Dec 7, 2005
    #12
  13. pemo

    pemo Guest

    "Richard Tobin" <> wrote in message
    news:dn70rj$s8m$...
    > In article <dn70b4$4s3$>, pemo <>
    > wrote:
    >>Ah, ok, so is -ansi the ANSI variant then?

    >
    > There isn't an "ANSI variant". ANSI standardised C in 1989. ISO
    > adopted that definition in 1990. ISO produced another standard in
    > 1999, which (apparently) ANSI adopted in 2000. So ANSI C is the same
    > as ISO C, and the versions can be referred to as C89 and C00 or C90
    > and C99 depending on which standards body you prefer.


    Sorry, not what I meant as a question [my fault], it was more what -ansi
    *means* as a gcc switch.

    OT here of course, but for completeness - here's what the manual says...

    The original ANSI C standard (X3.159-1989) was ratified in 1989 and
    published in 1990.
    This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later in
    1990. There
    were no technical differences between these publications, although the
    sections of the ANSI
    standard were renumbered and became clauses in the ISO standard. This
    standard, in
    both its forms, is commonly known as C89, or occasionally as C90, from the
    dates of
    ratification. The ANSI standard, but not the ISO standard, also came with a
    Rationale
    document. To select this standard in GCC, use one of the options '-ansi',
    '-std=c89' or
    '-std=iso9899:1990';
     
    pemo, Dec 7, 2005
    #13
  14. On 2005-12-07 11:22:27 -0500, "pemo" <> said:

    >
    > "Richard Tobin" <> wrote in message
    > news:dn70rj$s8m$...
    >> In article <dn70b4$4s3$>, pemo <> wrote:
    >>> Ah, ok, so is -ansi the ANSI variant then?

    >>
    >> There isn't an "ANSI variant". ANSI standardised C in 1989. ISO
    >> adopted that definition in 1990. ISO produced another standard in
    >> 1999, which (apparently) ANSI adopted in 2000. So ANSI C is the same
    >> as ISO C, and the versions can be referred to as C89 and C00 or C90
    >> and C99 depending on which standards body you prefer.

    >
    > Sorry, not what I meant as a question [my fault], it was more what
    > -ansi *means* as a gcc switch.
    >
    > OT here of course, but for completeness - here's what the manual says...
    >
    > The original ANSI C standard (X3.159-1989) was ratified in 1989 and
    > published in 1990.
    > This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later
    > in 1990. There
    > were no technical differences between these publications, although the
    > sections of the ANSI
    > standard were renumbered and became clauses in the ISO standard. This
    > standard, in
    > both its forms, is commonly known as C89, or occasionally as C90, from
    > the dates of
    > ratification. The ANSI standard, but not the ISO standard, also came
    > with a Rationale
    > document. To select this standard in GCC, use one of the options
    > '-ansi', '-std=c89' or
    > '-std=iso9899:1990';


    Well, the manual just told you; '-ansi' means the same as '-std=c89' or
    '-std=iso9899:1990'

    --
    Clark S. Cox, III
     
    Clark S. Cox III, Dec 7, 2005
    #14
  15. pemo

    pemo Guest

    "Clark S. Cox III" <> wrote in message
    news:2005120711335216807-clarkcox3@gmailcom...
    > On 2005-12-07 11:22:27 -0500, "pemo" <> said:
    >
    >>
    >> "Richard Tobin" <> wrote in message
    >> news:dn70rj$s8m$...
    >>> In article <dn70b4$4s3$>, pemo <>
    >>> wrote:
    >>>> Ah, ok, so is -ansi the ANSI variant then?
    >>>
    >>> There isn't an "ANSI variant". ANSI standardised C in 1989. ISO
    >>> adopted that definition in 1990. ISO produced another standard in
    >>> 1999, which (apparently) ANSI adopted in 2000. So ANSI C is the same
    >>> as ISO C, and the versions can be referred to as C89 and C00 or C90
    >>> and C99 depending on which standards body you prefer.

    >>
    >> Sorry, not what I meant as a question [my fault], it was more what -ansi
    >> *means* as a gcc switch.
    >>
    >> OT here of course, but for completeness - here's what the manual says...
    >>
    >> The original ANSI C standard (X3.159-1989) was ratified in 1989 and
    >> published in 1990.
    >> This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later
    >> in 1990. There
    >> were no technical differences between these publications, although the
    >> sections of the ANSI
    >> standard were renumbered and became clauses in the ISO standard. This
    >> standard, in
    >> both its forms, is commonly known as C89, or occasionally as C90, from
    >> the dates of
    >> ratification. The ANSI standard, but not the ISO standard, also came with
    >> a Rationale
    >> document. To select this standard in GCC, use one of the options '-ansi',
    >> '-std=c89' or
    >> '-std=iso9899:1990';

    >
    > Well, the manual just told you; '-ansi' means the same as '-std=c89' or
    > '-std=iso9899:1990'


    Um, yeah, I noticed! But thanks for pointing it out.
     
    pemo, Dec 7, 2005
    #15
  16. "pemo" <> writes:
    > [Warning] ISO C does not allow extra ';' outside of a function
    >
    > int n;;
    >
    > int main(void)
    > {
    > ...
    > }
    >
    > Anyone care to enlighten me as to why ISO C does not allow this, but
    > apparently ANSI c99 does?


    If "int n;;" appeared inside a function, it would be a declaration
    "int n;" followed by an empty statement ";". Since the grammar
    doesn't allow statements outside functions, "int n;;" outside a
    function is an error.

    As far as I know, this didn't change between C90 and C99; gcc seems to
    agree:

    % cat tmp.c
    int x;;
    % gcc --version | head -1
    gcc (GCC) 4.0.2
    % gcc -c -pedantic -std=c89 tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function
    % gcc -c -pedantic -std=iso9899:1990 tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function
    % gcc -c -pedantic -std=iso9899:199409 tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function
    % gcc -c -pedantic -std=c99 tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function
    % gcc -c -pedantic -std=c9x tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function
    % gcc -c -pedantic -std=iso9899:1999 tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function
    % gcc -c -pedantic -std=iso9899:1999 tmp.c
    tmp.c:1: warning: ISO C does not allow extra ';' outside of a function

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Dec 7, 2005
    #16
  17. pemo

    Jack Klein Guest

    On Wed, 7 Dec 2005 15:48:53 +0000 (UTC), Richard Heathfield
    <> wrote in comp.lang.c:

    > pemo said:
    >
    > > the message came from gcc and appears
    > > with -Wall -pedantic -std=c99

    >
    > Despite the flag name, gcc does not fully support C99.
    >
    > > So, I assume c99 is what you're caling c00?

    >
    > If you mean the ISO C Standard, it's C99. If you mean the ANSI C Standard,
    > it's C00.
    >
    > 1989: ANSI C (C89).
    > 1990: ISO C (C90) - this is effectively identical to C89, the only changes I
    > know about being section number changes.
    > 1995: There was a minor mod to the Standard which, I believe, was adopted by
    > both ISO and ANSI.
    > 1999: ISO C (C99).
    > 2000: ANSI C (C00 or C2000) - this is effectively identical to C99.
    >
    > Most people use C89 when they mean either C89 or C90, and C99 when they mean
    > either C99 or C00/C2000 - despite the fact that C89 refers to the ANSI
    > Standard and C99 refers to the ISO Standard.


    Sheesh, you are not only beating a dead horse, you are beating it
    incorrectly. The ANSI delegation to ISO voted to ratify the 1999
    version of the C standard at the same time that all other the member
    national standard bodies, except for the British who voted against it,
    did.

    Due to a procedural issue, meaning somebody at ANSI objected,
    ratification as an American National Standard required sending it out
    to their members as a vote. It was officially approved as an American
    National Standard on May 15, 2000.

    Nevertheless, if you point your favorite browser to:

    http://webstore.ansi.org/ansidocstore/product.asp?sku=INCITS/ISO/IEC 9899-1999

    ....you will see that for the princely sum of $18.00USD, you can still
    purchase:

    Document#: INCITS/ISO/IEC 9899-1999
    Title: Programming Languages - C (formerly ANSI/ISO/IEC
    9899-1999)

    The delay in ANSI approval as an American National Standard did not in
    any way change the date. ANSI C99 is "ANSI C99", not "ANSI C00" or
    "ANSI C2000". In fact, ANSI doesn't even call it an "ANSI" standard
    anymore.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Dec 8, 2005
    #17
  18. Jack Klein said:

    > On Wed, 7 Dec 2005 15:48:53 +0000 (UTC), Richard Heathfield
    > <> wrote in comp.lang.c:
    >
    >> Most people use C89 when they mean either C89 or C90, and C99 when they
    >> mean either C99 or C00/C2000 - despite the fact that C89 refers to the
    >> ANSI Standard and C99 refers to the ISO Standard.

    >
    > Sheesh, you are not only beating a dead horse,


    It's what we do here. :)

    > you are beating it incorrectly.


    That's more serious. Since you know far more about this than I do, I'm happy
    to accept the correction and apologise for supplying misinformation.

    Just out of curiosity, what's the right way to beat a dead horse?

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at above domain (but drop the www, obviously)
     
    Richard Heathfield, Dec 8, 2005
    #18
  19. Richard Heathfield wrote:
    >

    <snip>
    > I wasn't aware that executable code was allowed outside a function in C99.
    > C&V?
    >


    not the standart, but the C99 Rationale:

    <quote>
    5.1.2 Execution Environments

    The definition of program startup in the Standard is designed to permit
    initialization of static
    storage by executable code, as well as by data translated into the program image.
    </quote>

    so this should be valid (and compiles with -Wall -pedantic -std=c99):

    #include <string.h>

    size_t blah = strlen("abc");

    /*...*/
     
    Wolfgang Riedel, Dec 8, 2005
    #19
  20. pemo

    Simon Biber Guest

    Wolfgang Riedel wrote:
    > so this should be valid (and compiles with -Wall -pedantic -std=c99):
    >
    > #include <string.h>
    >
    > size_t blah = strlen("abc");
    >
    > /*...*/


    It's not valid, and gcc produces the diagnostic message "initializer
    element is not constant" when compiled with exactly the options you give.

    --
    Simon.
     
    Simon Biber, Dec 8, 2005
    #20
    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. Franck DARRAS
    Replies:
    12
    Views:
    663
    Jim Higson
    Aug 23, 2004
  2. Alexei Polkhanov
    Replies:
    11
    Views:
    2,491
  3. Replies:
    13
    Views:
    6,508
    Dave Thompson
    Dec 20, 2004
  4. ISO C89 and ISO C99

    , Dec 10, 2004, in forum: C Programming
    Replies:
    18
    Views:
    561
    Dave Thompson
    Dec 20, 2004
  5. pemo

    Reason for ISO ; warning

    pemo, Dec 7, 2005, in forum: C Programming
    Replies:
    0
    Views:
    270
Loading...

Share This Page