Thread: C89 or C99

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    Norway
    Posts
    11

    C89 or C99

    Hay there!

    Not sure whether I should write C89 or C99... I've been using C89 so far.
    How do I know when C99 is "available" for use? Does that only depend
    on the compiler, or compiler and libraries etc?

    I like that C99 has larger ints... other than that, I don't know much about
    the differences... I know that
    Code:
    for (int x = 0; ... ; ...) { ... }
    is allowed...
    Any other interested things? Also, are "evil" functions such as atoi() still
    available in C99? Have they deprecated anything at all?

    I use gcc on Linux/FreeBSD and Mingw on Windows.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by talin View Post
    How do I know when C99 is "available" for use? Does that only depend
    on the compiler, or compiler and libraries etc?
    Yes. Some compilers supports it, some does not. For example, GCC does support C99.

    I like that C99 has larger ints... other than that, I don't know much about
    the differences... I know that
    Code:
    for (int x = 0; ... ; ...) { ... }
    is allowed...
    Any other interested things?
    Well...
    Code:
    int n = 5;
    int myarray[n];
    ...works fine in C99.

    Also, are "evil" functions such as atoi() still
    available in C99? Have they deprecated anything at all?
    Still available.
    Last edited by Thantos; 05-26-2008 at 10:31 AM. Reason: Remove bad suggestion
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    396
    I like that C99 has larger ints... other than that, I don't know much about
    the differences
    Here's a quick summary:
    http://home.datacomm.ch/t_wolf/tw/c/c9x_changes.html

    and the current support status for gcc:
    http://gcc.gnu.org/c99status.html

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Elysia View Post
    Well...
    Code:
    int n = 5;
    int myarray[n];
    ...works fine in C99.
    Technically, I think what you describe is a compiler extension. In C99, it is required that you have "const int n = 5" - whilst gcc and MS also support you doing something like this:
    Code:
       int n;
       scanf("%d", &n);
       int array[n];
    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Oh ho! So people have been using compiler extensions all this time!
    Interesting.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Technically, I think what you describe is a compiler extension. In C99, it is required that you have "const int n = 5" - whilst gcc and MS also support you doing something like this:
    No, C99 really does allow for variable length arrays, though in the case of g++ it was ported over as a C++ compiler extension.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Registered User
    Join Date
    May 2008
    Location
    Norway
    Posts
    11
    Ah, great. Thanks for all the answers!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C99 C89
    By salvadoravi in forum C Programming
    Replies: 4
    Last Post: 01-21-2008, 07:43 AM
  2. My C89 RANT!
    By evildave in forum C Programming
    Replies: 12
    Last Post: 12-07-2005, 10:15 PM
  3. C99 and int main()
    By cwr in forum C Programming
    Replies: 8
    Last Post: 09-19-2005, 06:54 AM
  4. C89 and C99
    By Brain Cell in forum C Programming
    Replies: 5
    Last Post: 02-24-2005, 12:21 AM
  5. My first game
    By homeyg in forum Game Programming
    Replies: 20
    Last Post: 12-22-2004, 05:25 PM