为什么我的C头声明中出现语法错误?C语法 - 错误C2143:语法错误:在'*'之前缺少')'
这里是我的头文件,viterbi.h:
#ifndef VITERBI_H
#define VITERBI_H
void vitdec(float* , int , int , bool*);
#endif //VITERBI_H
这里是我的执行文件,viterbi.c:
// viterbi.c : Defines the entry point for the console application.
//
#include "viterbi.h"
#include "math.h"
//void vitdec(float* sd, int frameLen, int rate, bool* hd);
void vitdec(float* sd, int frameLen, int rate, bool* hd)
{
//... The rest of the function
从Visual Studio 2010编译器读取的错误:
viterbi.h(4): error C2143: syntax error : missing ')' before '*'
viterbi.h(4): error C2081: 'bool' : name in formal parameter list illegal
viterbi.h(4): error C2143: syntax error : missing '{' before '*'
viterbi.h(4): error C2059: syntax error : ')'
viterbi.h(4): error C2059: syntax error : ';'
viterbi.c(7): error C2065: 'bool' : undeclared identifier
viterbi.c(7): error C2065: 'hd' : undeclared identifier
viterbi.c(7): warning C4552: '*' : operator has no effect; expected operator with side-effect
据我所见/可以告诉,这是C声明的有效语法。如果我将viterbi.c编译为C++代码(viterbi.cpp),那么错误消失。什么是语法错误?
有没有这样的事情在''C' bool'(89)。你想用Visual Studio编译'C'代码,那么你必须编写'C'代码,而不是'C++'代码。 – PaulMcKenzie
看起来像'bool'可能是问题所在:http://stackoverflow.com/a/18042253 – jonhopkins
@PaulMcKenzie:'bool'是一个映射到**标准类型**'_Bool'的宏。并且有建议不要在应用程序中重新定义'bool'等。而C不是C89,而是标准C,它只是** C11。 – Olaf