How universally is C99 supported?

10,246

Solution 1

If you want to write portable C code, then I'd suggest you to write in C89 (old ANSI C standard). This standard is supported by most compilers.

The Intel C Compiler has very good C99 support and it produces fast binaries. (Thanks 0x69!)

MSVC supports some new features and Microsoft plan to broaden support in future versions.

GCC supports some new things of C99. They created a table about the status of C99 features. Probably the most usable feature of C99 is the variable length array, and GCC supports it now. Clang (LLVM's C fronted) supports most features except floating-point pragmas.

Wikipedia seems to have a nice summary of C99 support of the compilers.

Solution 2

Someone mentioned the Intel compiler has C99 support. There is also the Comeau C/C++ compiler which fully supports C99. These are the only ones I'm aware of.

C99 features that I do not use because they are not well supported include:

  • variable length arrays
  • macros with variable number of parameters.

C99 features that I regularly use that seem to be pretty well supported (except by Microsoft):

  • stdint.h
  • snprintf() - MS has a non-standard _snprintf() that has serious limitations of not always null terminating the buffer and not indicating how big the buffer should be

To work around Microsoft's non-support, I use a public domain stdint.h from MinGW (that I modified to also work on VC6) and a nearly public domain snprintf() from Holger Weiss

Items that are not supported by Microsoft, but will still use on other compilers depending on the project include:

  • mixed declarations and code
  • inline functions
  • _Pragma() - this makes pragmas much more usable

Solution 3

For gcc, there is a table with all supported features. It seems to be that the biggest thing missing are variable-length arrays. Most of the other missing features are library issues rather than language features.

Solution 4

The IBM c compiler has c99 support when invoked as c99 but not when invoked as cc or xlc.

Solution 5

Look at C99 suport status for GNU for details on which features are supported currently.

Sun Studio is purported to support the entire C99 spec. I have never used them, so I can't confirm.

I don't believe the microsoft compiler supports the C99 spec in its entirety. They are much more focused on C++ at the moment

Share:
10,246

Related videos on Youtube

Eli Bendersky
Author by

Eli Bendersky

Blog Github

Updated on December 07, 2020

Comments

  • Eli Bendersky
    Eli Bendersky over 3 years

    How universally is the C99 standard supported in today's compilers? I understand that not even GCC fully supports it. Is this right?

    Which features of C99 are supported more than others, i.e. which can I use to be quite sure that most compilers will understand me?

    • Peter Cordes
      Peter Cordes over 14 years
      don't forget libraries. Besides nice syntax (like named struct initializers), C99 adds many useful math library functions, like long lrtint(double); which does the fast rounding operation you otherwise have to hack up like (long)(x + 0.5).
    • Z boson
      Z boson over 10 years
      The Portland Group's high performance PGCC compiler is 100% C99 compliant.
  • Eli Bendersky
    Eli Bendersky almost 16 years
    By ANSI C, do you mean C89/C90 ? Because ANSI C and ISO C used to be synonymous, but I understand that now ISO C refers to C99
  • u0b34a0f6ae
    u0b34a0f6ae about 14 years
    GCC 4.5 finally lists variable length arrays as Done and not Broken!
  • Sultan
    Sultan about 14 years
    @kaizer.se : Thanks for letting us know.
  • PeterK
    PeterK about 14 years
    Mu question could also bring you some relevant info on this topic: stackoverflow.com/questions/3093049/…
  • Remover
    Remover almost 14 years
    variable length arrays are broken in GCC 4.2 (for anyone using xcode 3.2.3 as standard)
  • osgx
    osgx about 13 years
    There must be option like it is for gnu with -std=c99
  • frankster
    frankster almost 13 years
    @osgx yes that is correct: you could use the option -qlanglvl=stdc99 for example
  • Michael Burr
    Michael Burr almost 13 years
    Yes - VS2010 added some of the C99 things that were incorporated into C++0x. stdint.h being one of the more important additions.
  • Agnius Vasiliauskas
    Agnius Vasiliauskas about 12 years
    -1. Intel doesn't have full support of c99. It is missing long double's
  • Agnius Vasiliauskas
    Agnius Vasiliauskas about 12 years
    Also it is interesting to note that non-commercial versions of Intel compilers are only available for Linux.
  • Étienne
    Étienne about 10 years
    VLAs are fully supported since gcc 4.5.
  • Étienne
    Étienne about 10 years
    Visual Studio has added some support for C99 in its latest version and announced that more will be added in the next versions, the last sentence of this answer is outdated.
  • Étienne
    Étienne about 10 years
    VS2013 supports mixed declarations and code and snprintf is planned in the next revision of Visual Studio.