【发布时间】:2014-01-27 00:29:44
【问题描述】:
我试图在 C++ 中创建这个类,但编译器在它的声明中不断给我一个语法错误。全局变量是必需的。
这是错误信息
include\SInterface.h(36):错误 C2061:语法错误:标识符 'SInterfaceClass'
#ifndef __SINTHDR__
#define __SINTHDR__
#include "Global.h"
typedef unsigned int uint;
typedef struct
{
float d1;
float d2;
float d3;
float d4;
float para;
float mode;
} DeflStruct;
// Simulation Inputs
// ====================================================================
float SimAcc [3] = {0};
float SimGyr [3] = {0};
//
// More Global floats being defined here
//
float SimOutPara = 0 ;
float SimOutMode = 0 ;
class SInterfaceClass { // line 36
private:
float ITime;
float IPrevTime;
//
// More floats being defined here
//
float Ic1_bf_psi_rate;
float Ic1_bf_phi_rate;
public:
SInterfaceClass();
DeflStruct Output(
Vect3 Acc ,
Vect3 Gyr ,
double Pre ,
Vect3 Vel ,
Vect3 Eul ,
Vect3 Inc ,
Vect3 Pos ,
double Time);
};
#endif
【问题讨论】:
-
您为什么使用
typedef struct而不仅仅是struct? -
有什么重要的 int
Global.h? -
这个类是接口的一部分,应该将纯 C 语言编写的程序连接到 Simulink/Matlab 仿真模型。就在这之前,我正在研究它,并且是自动完成的。
-
等等,你是用 C 还是 C++ 编译? C 没有类。
-
发布一个重现此错误的 complete sn-p。正如所写的,不包括
Global.h愉快地通过标记线而没有错误并继续直到Vect3成员,其中当然无效,因为没有Global.h。
标签: c++ class syntax-error declaration