Thread: Dev-Cpp and the Standard

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

    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
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

  5. #5
    Registered User Micko's Avatar
    Join Date
    Nov 2003
    Posts
    715
    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
    6,815
    It's legal in C99, but is not legal in C++.

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

Popular pages Recent additions subscribe to a feed