C89 or C99

This is a discussion on C89 or C99 within the C Programming forums, part of the General Programming Boards category; Hay there! Not sure whether I should write C89 or C99... I've been using C89 so far. How do I ...

  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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,538
    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
    395
    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をこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,538
    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
    21,603
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 06:43 AM
  2. My C89 RANT!
    By evildave in forum C Programming
    Replies: 12
    Last Post: 12-07-2005, 09: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-23-2005, 11:21 PM
  5. My first game
    By homeyg in forum Game Programming
    Replies: 20
    Last Post: 12-22-2004, 04:25 PM

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