Different behavior of compilers with array allocation

眉间皱痕 提交于 2019-12-01 17:31:21

C99 (the most recent version of the C standard) does allow dynamically sized arrays. However, the feature is not supported by Visual Studio (which only implements C89 support)

In C++ it is not, and probably will never be, valid.

Dynamically sized arrays are a feature of C99. If your compiler supports C99 (GCC does, VC doesn't fully) - and if you throw the C99 switch -, then this will compile.

This is not standard C++ (but standard C). Implementations may provide alloca (or _alloca with msvc) which pretty much does the job.

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