Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the point of the C99 standard?

Tags:

c

c99

C99 adds several useful features to the language, yet I find it difficult to recommend any practice which depends upon C99. The reason for this is because there are few (any?) actual implementations of the C99 language. Sure, there is limited support in a few compilers, but nobody wants spend the time to write C code only to have it be unportable.

This is frustrating given that the standard was written and finalized over 10 years ago now. Plus I hear discussions of a C1x from time to time, and I wonder why someone would be taking steps to revise the language given that the current version of the language isn't yet implemented.

So my question is, as joe blow C programmer today, what is useful w.r.t. the C99 standard to me (if any)?

like image 677
Billy ONeal Avatar asked Nov 21 '10 23:11

Billy ONeal


People also ask

What is C99 used for?

C99 is a step ahead in the evolution of ANSI C. It incorporates elegant features like single line comments, boolean data types and larger size data types. C99 also supports code optimization through restricted pointer usage and supports inline functions.

Is C99 the same as C?

C99 is a standard of the C language published by ISO and adopted by ANSI in around 1999. GNU C is just an extension of c89,while some features of c99 are also added,but in entirety it is different from c99 standard so when compiling in gcc we have to enter -std=c99 which is already mentioned in the other answers.

Should I use C99 or C11?

It is best to use C11 as that is the current standard. C99 and C11 both contained various "language bug fixes" and introduced new, useful features.

What is language standard C99?

C99 introduced several new features, including inline functions, several new data types (including long long int and a complex type to represent complex numbers), variable-length arrays and flexible array members, improved support for IEEE 754 floating point, support for variadic macros (macros of variable arity), and ...


2 Answers

C99 brings features that really makes programming in C easier and more error safe:

  • designated initializers
  • compound literals
  • for-scope variables
  • fixed width integer types

The language is also much more expressive with

  • variadic macros
  • inline functions

On my linux machine I have four compilers that support C99 to a satisfying extent that make this usable on a daily base: gcc, clang, opencc and icc.

The first two are open source compilers where clang trying to be code compatible to gcc (meaning C99 support is about the same).

The later two are from the two major CPU producers and are commercial but with generous license policy for non commercial users. Their C99 is a bit less, in particular their support for inline seems not completely consistent with the standard, yet.

like image 100
Jens Gustedt Avatar answered Oct 08 '22 02:10

Jens Gustedt


MSVC does not, nor will it probably ever, support C99. But Microsoft has little incentive to update their C compiler. It's not like they will lose much business over it.

But there are plenty of compilers that have support for C99.

http://en.wikipedia.org/wiki/C99#Implementations

Regarding gcc:

http://gcc.gnu.org/c99status.html

You are right that perhaps C99 is not useful for library code (and may never be without Microsoft's support), but if you're working on an in-house or personal project where you can pick the compilers and tools, then the portability is not much of an issue.

like image 40
Matthew Avatar answered Oct 08 '22 01:10

Matthew