Dev-Cpp and the Standard

This is a discussion on Dev-Cpp and the Standard within the C Programming forums, part of the General Programming Boards category; Hello people, I've used to work with Dev-Cpp for more than a year, but only yesterday I've noticed that this ...

  1. #1
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712

    Dev-Cpp and the Standard

    Hello people,
    I've used to work with Dev-Cpp for more than a year, but only yesterday I've noticed that this code is compiled OK.
    Code:
    int main ( void )
    {
    	int size = 10;
    	char test[size];
    }
    Does anyone know other bugs (if I can call it that way)?
    Also does this mean that in past this was legal but Standard made new rules?

    Thanks
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  2. #2
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    I think that's allowed in the C99 standard and GCC has the biggest support for it.
    http://gcc.gnu.org/c99status.html

  3. #3
    Sys.os_type="Unix";;
    Join Date
    Aug 2005
    Posts
    52
    You're probably just compiling that code as C++ code.
    Or it's defaulting to using C99 standard as I think that's legal in C99.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Adding
    -ansi -pedantic
    makes a pretty good job of making sure you don't slip into compiler specific extensions.

    Also choose one of
    -std=c89
    -std=c99
    if you're using a really new GNU compiler, and want to make sure your code is to a specific standard.

    -W -Wall -O2
    flush out lots of other interesting stuff which may present problems.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    712
    Well, I didn't know it's legal in C99. I learned something new today
    Gotta love the "please fix this for me, but I'm not going to tell you which functions we're allowed to use" posts.
    It's like teaching people to walk by first breaking their legs - muppet teachers! - Salem

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    5,883
    It's legal in C99, but is not legal in C++.

  7. #7
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498
    Yeah, that code does not compile on GCC 4.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21