为什么VS2010给语法错误时,语法是正确的? [英] Why does VS2010 give syntax errors when syntax is correct?
问题描述
我有VS2010(和VS2008)问题给我的语法错误的一大名单。但是,语法是确实是正确的。这里是一个小例子;
我有.h文件里面以下code座
//原型声明
LIST * createList(INT(*比较)(void *的,无效*));
LIST * destroyList(LIST *的plist);
INT ADDNODE(LIST * plist中,无效* dataInPtr);
布尔的removeNode(LIST * plist中,无效* keyPtr,无效** dataOutPtr);
布尔searchList(LIST * plist中,无效* pArgu,无效** pDataOut);
布尔retrieveNode(LIST * plist中,无效* pArgu,无效** dataOutPtr);
布尔移动(LIST * plist中,诠释fromWhere,无效** dataOutPtr);
INT listCount(LIST * plist)的难度;
布尔isListEmpty(LIST * plist)的难度;
布尔isListFull(LIST * plist)的难度;
LIST是一个typedef定义结构,仅供参考。所有这些函数声明似乎是正确的语法。然而,试图建立的时候,我得到了从第一个布尔函数以下语法错误,将在列表中向下。
错误2错误C2059:语法错误:';'
块引用>我没有看到问题所在。同样,这只是一个小例子。我也收到语法错误,如以下
布尔发现;
错误29错误C2065:布尔:未声明的标识符
块引用>我真的在失去了这一个。张贴在这里code不是我自己的,它从一个数据结构本书的,但同样它看起来是正确的。任何帮助将是AP preciated。谢谢!
解决方案
布尔
是不是在C基本类型。的Visual C ++只实现了C90,它没有
布尔
类型。 C99添加通过&LT为
头,但Visual C ++不支持此布尔
支持; stdbool.h方式>您应该要么使用
INT
或创建自己的typedef布尔
。I am having a problem with VS2010 (and VS2008) giving my a great list of syntax errors. However, the syntax is indeed correct. Here is a small example;
I have the following code block inside a .h file
// Prototype Declarations LIST* createList (int (*compare) (void*, void*)); LIST* destroyList (LIST* plist); int addNode (LIST* pList, void* dataInPtr); bool removeNode (LIST* pList, void* keyPtr, void** dataOutPtr); bool searchList (LIST* pList, void* pArgu, void** pDataOut); bool retrieveNode (LIST* pList, void* pArgu, void** dataOutPtr); bool traverse (LIST* pList, int fromWhere, void** dataOutPtr); int listCount (LIST* pList); bool isListEmpty (LIST* pList); bool isListFull (LIST* pList);
LIST is a typedef'd struct, FYI. All of these function declarations appear to be correct syntax. Yet, when attempting to build, I get the following syntax errors starting at the first bool function, going down the list.
Error 2 error C2059: syntax error : ';'
I'm failing to see where the problem lies. Again, this is just a small example. I also receive syntax errors such as the following
bool found;
Error 29 error C2065: 'bool' : undeclared identifier
I'm truly at a lost on this one. The code posted here isn't my own, it's from a data structures book, but again it looks correct. Any help would be appreciated. Thanks!
解决方案
bool
is not a fundamental type in C.Visual C++ only implements C90, which has no
bool
type. C99 added support forbool
via the<stdbool.h>
header, but Visual C++ does not support this.You should either use
int
or create your own typedef forbool
.这篇关于为什么VS2010给语法错误时,语法是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!