Why does VS2010 give syntax errors when syntax is correct?

北城以北 提交于 2019-11-29 11:55:27

bool is not a fundamental type in C.

Visual C++ only implements C90, which has no bool type. C99 added support for bool via the <stdbool.h> header, but Visual C++ does not support this.

You should either use int or create your own typedef for bool.

Check the file extension of the file including that header.

Visual Studio will automatically compile .c files as C rather than C++ if you don't tell it to do any differently (in the project settings).

Visual Studio's "C" support is... interesting - to my understanding it is in fact C89 rather than C99, and you can't just flick a switch to get C99. C89/C99 aside, bool is not a builtin type in C.

You can rename all your files to .cpp to compile them as C++, or modify the project settings to force compilation as C++ for every .c/.cpp/.cc file in the project.

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