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?

4
  • 3
    When did "some" say that? Feb 22, 2011 at 19:28
  • @Crazy Eddie: Books on C, different articles on the web
    – Anto
    Feb 22, 2011 at 19:29
  • 1
    I guess a better wording for this question would be: "How widely implemented is C99?" Feb 22, 2011 at 19:43
  • @chrisaycock: I want to know wether or not to use C99 features; the wideness of implementation is just something that my question happen to depend on
    – Anto
    Feb 22, 2011 at 19:45

3 Answers 3

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.

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

2
  • 2
    C99 works especially well on VS? Maybe if you plug-in Intel's compiler. Feb 22, 2011 at 21:17
  • Of course... Although various systems come with this as standard.
    – dbramhall
    Feb 22, 2011 at 21:56
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.

1
  • 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, 2014 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.