5

Some seem to say that one should avoid C99 features in C code as compilers don't really support those features. C99 is a standard from 1999, shouldn't these features be quite widespread now?

Should one avoid using C99 features in new code? In legacy code? I happen to use some C99 features quite often, should I stop doing that or be more careful with the use of those features?

Anto
  • 11,157
  • 13
  • 67
  • 103

3 Answers3

6

Not at all. I would highly recommend using C99 code as, with anything really, it's standardized. The compatibility between compilers is always going to vary and frustrate but it's important to embrace standardization and simply embrace what developers SHOULD, theoretically, be using. I use C99 day-in-day-out and, apart from some hoo-ha with variadic macros, everything works well, especially on VS and Xcode (obviously).

dbramhall
  • 1,751
  • 1
  • 14
  • 18
4

Depends on how portable your code needs to be. C compilers support C99 features to a very different degree, and that can be a problem. See here for details: http://en.wikipedia.org/wiki/C99#Implementations

Personally, I would stick with C89/C90 unless I was certain I would always compile the code with the same compiler.

Nemanja Trifunovic
  • 6,815
  • 1
  • 26
  • 34
3

Despite C99's age, support remains spotty in several compilers (such as Microsoft Visual C++). Some C99 features, such as variadic macros, are supported by many compilers; other features, not so much. So you'll need to evaluate your cross-platform needs and decide if the compilers you'll need to use will support the features you want.

A second consideration is that C99 diverges more from C++. If you don't plan on ever incorporating C++, this is not an issue.

Josh Kelley
  • 10,991
  • 7
  • 38
  • 50
  • 1
    Well, from the various comments by MS and MS developers, you can learn VS C++ isn't really meant as a C compiler (as the name implies) - it's a C++ compiler that supports some C for legacy code. If you develop new code in C, VS C++ is simply not the right compiler to use (however, you can use the IDE and plug in a different compiler, with some limitations). – sleske Aug 25 '14 at 12:01