我想在MS VS 2010下编译一个较旧的C代码。错误发生在结构声明和调用。在VS 2010编译C代码
宣言(编辑):
typedef struct tStr
{
int nInt;
int ***anPoint;
};
用法:
struct tStr tStuff;
tStuff.nInt = 0;
函数声明(编辑:也许现在的工作):
int doStuff(struct tStr *sStuff, int nStuff);
编译器抱怨不明身份的标识,缺(或;或{等等,它们都被归类为语法错误,我检查的语法应该是好的。所以我在我的最后...
我redid结构声明。但仍然是相同的错误:
error C2143: syntax error : missing ';' before 'type'
好吧,回到旧的声明。但是,如果我尝试访问该结构变量在使用中,我得到一个错误:
error C2065: 'tStuff' : undeclared identifier
所以我的生活代码:
typedef struct tMatrix
{
int nRows;
int nCols;
int nVec;
int ***anMatrix;
};
int allocateMatrix(struct tMatrix *sMatrix, int nType);
struct tMatrix sMatrix1;
sMatrix1.nRows = 0;
的错误:
error C2143: syntax error : missing ';' before 'type'
error C2065: 'sMatrix1' : undeclared identifier
任何想法?
编辑:谢谢你所有的答案,我想我会重写它。我还会得到更多关于类型转换的其他错误,所以...为了避免头痛,我会刚刚开始新鲜。再次感谢。
片段看起来不错。你能提供一个完整的,但很小的例子来证明问题吗? – Lindydancer 2011-12-31 16:15:15
请显示出现问题的短片段。另请注意,Visual Studio只包含一个C++编译器,因此您的代码将始终以C++编译,并且只支持C89标准中的那些C部分。 – Xeo 2011-12-31 16:16:56
我们可以看到错误信息吗? – 2011-12-31 16:17:07