Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
3  
When did "some" say that? –  Crazy Eddie Feb 22 '11 at 19:28
    
@Crazy Eddie: Books on C, different articles on the web –  Anto Feb 22 '11 at 19:29
1  
I guess a better wording for this question would be: "How widely implemented is C99?" –  chrisaycock Feb 22 '11 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 '11 at 19:45
add comment

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
1  
C99 works especially well on VS? Maybe if you plug-in Intel's compiler. –  Nemanja Trifunovic Feb 22 '11 at 21:17
    
Of course... Although various systems come with this as standard. –  dbramhall Feb 22 '11 at 21:56
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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