c99

This is a discussion on c99 within the C Programming forums, part of the General Programming Boards category; c99 doesn't seem like it has been much of a priority as a standard to implement since it was published, ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    55

    c99

    c99 doesn't seem like it has been much of a priority as a standard to implement since it was published, am I right? GCC implements some but not all of it, VC++ doesn't support it (I don't think), and I think I read that borland doesn't really either. Will c99 eventually become more prominent(maybe it is and I just don't realize it)? Would it be a good idea to stay away from writing code that works with c99 but not earlier standards?

  2. #2
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    983
    It's probably a good idea to stay away from C99 if you're planning on having other people build the code. As you say, C99 just isn't widespread currently. However, it's not completely ignored.

    Intel's C compiler supports a good chunk of C99 (I seem to recall reading that it supports all but one or two small features, but don't quote me); Sun Studio also has support for a lot of C99. clang, while still not mature, aims to be able to be dropped in, more or less, as a gcc replacement, which means it supports or will support the C99 features that gcc has.

    I make use of some C99 features with gcc when I'm writing code for myself. My code all builds fine with icc as well. Sun's compiler doesn't care as much about being a gcc replacement as icc and so some things won't build with it; but that's mainly (or, perhaps, solely) because I have a lot of projects that make use of gcc's -include option. Sun's compiler has worked fine with my C99 projects that use "standard" compiler options.

    I'm not sure if vc++ will ever go C99; but if you're targeting unixy systems, there's a good chance you can safely use a lot of C99 features. It's just up to you to decide whether limiting the number of potential users is worth it.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,596
    Quote Originally Posted by cas View Post
    I'm not sure if vc++ will ever go C99...
    Highly unlikely. C just doesn't seem like a language that fits in on the systems that Microsoft's build tools aim at.
    Still, it may be a good idea to borrow some things from C99 that works with C90, as well, such as demanding the use of headers and not using implicit function types. They are removed in C99.
    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.

  4. #4
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    I'm quite certain that nearly everyone of you is making constant use of C99 features, such as C++ comments:

    Code:
    $ cat -n foo.c 
         1	int main()
         2	{
         3		// no comment
         4		return 0;
         5	}
         6	
    $ gcc -std=c89 foo.c 
    foo.c: In function ‘main’:
    foo.c:3: error: expected expression before ‘/’ token
    $ 
    There are a lot of features I regard to be completely useless, but some of them are quite nice, e.g. variable long argument lists for macros, a native boolean type, stdint.h and the like. I'm sure that either the C compilers or the standard adjust(s) itself within the next years.

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Gcc may have this intent judging from this:

    gnu99
    GNU dialect of ISO C99. When ISO C99 is fully implemented in
    GCC, this will become the default.

    This is a switch (eg. -std=c99 or -std=gnu99).
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I think MS wants everyone to move to C# really, but if not that, then they want C++ rather than C, so they are not doing much to update their version of C.

    Other compiler vendors follow C99 more closely.

    Obviously, for VERY portable code, avoid C99.

    If you want REASONABLY portable code, then some of the commonly implemented features that came from C++ is often available in C compilers too (particularly in those that have use the same compiler engine for both). Clearly using C++ style comments is almost always supported. Having variable declarations "not at the beginning of a block" is also quite common.

    It REALLY comes down to "how portable do you want the code to be?". And that in turn means "What compilers are your customers/clients/users likely to use?", and when you know that answer, figure out what the common factors are. If the list is LONG, then you need to think hard about whether you want to ensure that you use C89-compatible code alone, or you limit the choice of compilers. After all, it's a balance - maybe there aren't that many people that will need to compile it on VAX/VMS ANSI C compiler, but a lot of people will have access to MS or gcc compilers.

    --
    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.

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,596
    Quote Originally Posted by matsp View Post
    I think MS wants everyone to move to C# really, but if not that, then they want C++ rather than C, so they are not doing much to update their version of C.
    I would find that quite likely, but so far they are also throwing out full support to C++ developers, as well. So MS supports C++ and C#, although to a different extent. C# getting more stuff than C++ mostly.
    Regardless, since Microsoft's toolset is for building for modern technologies, there isn't much demand for C I reckon. So I would agree with mats.
    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.

  8. #8
    UK2
    Join Date
    Sep 2003
    Posts
    112
    Hello,

    I was just reading this post. And just wondering how do you know if your compiler supports C99? I guess some features might be supported and some might not. But how would you know which ones?

    Currently I am working on a project that has to run on linux and windows. I am using GNC gcc:
    Installed Packages
    Name : gcc
    Arch : i386
    Version: 4.1.1
    Release: 52.el5

    Many thanks,

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,717
    Quote Originally Posted by steve1_rm
    And just wondering how do you know if your compiler supports C99? I guess some features might be supported and some might not. But how would you know which ones?
    Read your compiler's documentation
    Of course, you could also write test programs and see if they compile and work as the 1999 edition of the C standard says they should, but then you would might not know if the feature was officially supported or just a "misbug".

    Quote Originally Posted by steve1_rm
    Currently I am working on a project that has to run on linux and windows. I am using GNC gcc:
    Refer to the GCC online documentation; in particular: Status of C99 features in GCC 4.1.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C89 or C99
    By talin in forum C Programming
    Replies: 6
    Last Post: 05-26-2008, 12:45 PM
  2. C99 and int main()
    By cwr in forum C Programming
    Replies: 8
    Last Post: 09-19-2005, 06:54 AM
  3. C99 support?
    By Devil Panther in forum C Programming
    Replies: 3
    Last Post: 08-22-2005, 02:07 PM
  4. C99 mode??
    By 7smurfs in forum C Programming
    Replies: 3
    Last Post: 03-23-2005, 02:07 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