dumb q moving to gcc - c99 mode

Discussion in 'C Programming' started by MikeyD, Sep 19, 2003.

  1. MikeyD

    MikeyD Guest

    Just switched to using gcc on my windows 98 pc. Programs were compiling fine
    on a propriety compiler. Now, though, it gives me an error message for a for
    loop, "line xx: use of header-defined for loop outside of c99 mode". What is
    this?
    MikeyD, Sep 19, 2003
    #1
    1. Advertising

  2. On Fri, 19 Sep 2003 20:14:49 +0100
    "MikeyD" <> wrote:
    > Just switched to using gcc on my windows 98 pc. Programs were compiling fine
    > on a propriety compiler. Now, though, it gives me an error message for a for
    > loop, "line xx: use of header-defined for loop outside of c99 mode". What is
    > this?


    Post the smallest compilable snippet triggering this error.

    --
    char*x(c,k,s)char*k,*s;{if(!k)return*s-36?x(0,0,s+1):s;if(s)if(*s)c=10+(c?(x(
    c,k,0),x(c,k+=*s-c,s+1),*k):(x(*s,k,s+1),0));else c=10;printf(&x(~0,0,k)[c-~-
    c+"1"[~c<-c]],c);}main(){x(0,"^[kXc6]dn_eaoh$%c","-34*1'.+(,03#;+,)/'///*");}
    Pieter Droogendijk, Sep 19, 2003
    #2
    1. Advertising

  3. "MikeyD" <> wrote in
    news::

    > Just switched to using gcc on my windows 98 pc. Programs were compiling
    > fine on a propriety compiler. Now, though, it gives me an error message
    > for a for loop, "line xx: use of header-defined for loop outside of c99
    > mode". What is this?


    Not sure, I can't read your mind. Show us a very small example of the
    problem code.

    --
    - Mark ->
    --
    Mark A. Odell, Sep 19, 2003
    #3
  4. MikeyD

    Mac Guest

    On Fri, 19 Sep 2003 20:14:49 +0100, MikeyD wrote:

    >
    > Just switched to using gcc on my windows 98 pc. Programs were compiling fine
    > on a propriety compiler. Now, though, it gives me an error message for a for
    > loop, "line xx: use of header-defined for loop outside of c99 mode". What is
    > this?



    I don't know exactly what the message means, but there must be some way to
    invoke gcc so that it is more permissive. Maybe check out the
    documentation for gcc. Do a "man gcc" or a "gcc --help".

    From the context, I am pretty sure that "c99 mode" means a mode where gcc
    allows some of the features from the c standard as ratified in 1999 (as
    opposed to the previous standard which is usually called c89).

    So, since it sounds like it has something to do with c99, try searching
    through the documentation for "c99." I'm sure you'll find a solution. ;-)


    Mac
    --
    Mac, Sep 20, 2003
    #4
  5. MikeyD

    Simon Biber Guest

    "MikeyD" <> wrote:
    > Just switched to using gcc on my windows 98 pc. Programs were compiling fine
    > on a propriety compiler. Now, though, it gives me an error message for a for
    > loop, "line xx: use of header-defined for loop outside of c99 mode". What is
    > this?


    I don't know that error message specifically. However it's probably similar to:

    int main(void)
    {
    for(int i = 0; i < 10; i++);
    return 0;
    }

    C:\prog\c>gcc mikeyd.c
    mikeyd.c: In function `main':
    mikeyd.c:3: `for' loop initial declaration used outside C99 mode

    You can fix this by just adding -std=c99 to the command line.

    Or, if you want the code to function properly on older compilers, you
    will need to move all the declarations out of the for loops whenever
    this occurs.

    --
    Simon.
    Simon Biber, Sep 20, 2003
    #5
  6. MikeyD

    MikeyD Guest

    "Pieter Droogendijk" <> wrote in message
    news:...
    > On Fri, 19 Sep 2003 20:14:49 +0100
    > "MikeyD" <> wrote:
    > > Just switched to using gcc on my windows 98 pc. Programs were compiling

    fine
    > > on a propriety compiler. Now, though, it gives me an error message for a

    for
    > > loop, "line xx: use of header-defined for loop outside of c99 mode".

    What is
    > > this?

    >
    > Post the smallest compilable snippet triggering this error.
    >

    #include <stdio.h>
    int main(void){
    for(int i=1;i<10;i++)
    printf("%d",i);
    return 0;
    }
    I may have mixed up error messages, since I'm now getting "test.c:3: error:
    'for' loop initial declaration used outside c99 mode"
    MikeyD, Sep 20, 2003
    #6
  7. MikeyD

    Mac Guest

    On Sat, 20 Sep 2003 17:55:44 +1000, Simon Biber wrote:

    > I don't know that error message specifically. However it's probably
    > similar to:
    >
    > int main(void)
    > {
    > for(int i = 0; i < 10; i++);
    > return 0;
    > }
    >
    > C:\prog\c>gcc mikeyd.c
    > mikeyd.c: In function `main':
    > mikeyd.c:3: `for' loop initial declaration used outside C99 mode
    >
    > You can fix this by just adding -std=c99 to the command line.


    And making sure you don't also use -ansi, as this seems to override
    -std=c99.

    Mac
    --
    Mac, Sep 21, 2003
    #7
  8. MikeyD wrote:
    > #include <stdio.h>
    > int main(void){
    > for(int i=1;i<10;i++)
    > printf("%d",i);
    > return 0;
    > }
    > I may have mixed up error messages, since I'm now getting "test.c:3: error:
    > 'for' loop initial declaration used outside c99 mode"


    The problem is that in C you can't declare a variable at the initialization part
    of the for-loop as you can in C++ for example. That's changed though in C99,
    that's why the compiler tells you that either your code is wrong, or you forgot
    to tell it you are writing C99.

    -- Nuclear / the Lab --
    John Tsiombikas (Nuclear / the Lab), Sep 21, 2003
    #8
    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. 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:
    632
    Kevin P. Fleming
    Nov 6, 2003
  2. John J Lee
    Replies:
    3
    Views:
    456
    bruno at modulix
    Dec 1, 2005
  3. Replies:
    3
    Views:
    3,646
    Chris Torek
    Feb 20, 2006
  4. Replies:
    3
    Views:
    582
    Keith Thompson
    Mar 31, 2007
  5. Jerry C.
    Replies:
    8
    Views:
    207
    Uri Guttman
    Nov 23, 2003
Loading...

Share This Page