What is the point of the C99 standard?

匆匆过客 提交于 2019-12-03 23:36:08

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.

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.

Regarding C1x, I think it's worth noting that the standards committee is well aware that C99 has not been widely adopted and doesn't want to repeat the same mistakes (or to make the situation worse). From the C1x charter:

Unlike for C9X, the consensus at the London meeting was that there should be no invention, without exception. Only those features that have a history and are in common use by a commercial implementation should be considered. Also there must be care to standardize these features in a way that would make the Standard and the commercial implementation compatible.

And:

The original standard had a very positive reception from both the user and vendor communities. However, C99 has been not so widely received.

You should use C99 whenever you are not locked in an environment that doesn't support C99 (embeded systems most notably).

And yes, if you know that your library will be used by people that are using MSVC, you can't use C99 features in the interfaces, but there is no reason not to use C99 in the implementation (apart from library feature dependencies of course).

Original answer: "Uh? What compilers don't support C99? Plus when you move from compilers to tools, C99 is actually more commonly supported then C89."

If you care for performance, there's no way around restrict.

FreeBSD is now using Clang for kernel compiles and that pretty much supports C99.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!