G 将函数返回struct的原型混淆为结构初始化器
G++ confuses prototype of function returning struct as struct initializer
编译项目时,我会收到以下错误:
drawplant.h: In function 'Matrix3f current_matrix()':
drawplant.h:26:1: error: only constructors take member initializers
Matrix3f mmmult(Matrix3f, Matrix3f);
这是drawplant.h:
#ifndef _DRAWPLANT_H_
#define _DRAWPLANT_H_
/* Functions implemented in drawplant.cpp */
#define PI 3.14159265358
struct Vector3f{
GLdouble v[4];
} typedef Vector3f;
struct Matrix3f{
GLdouble m[16];
} typedef Matrix3f;
extern int depth;
void drawPlant();
void push();
void pop();
//void rotate(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
//void translate(GLdouble, GLdouble, GLdouble);
//void scale(GLdouble, GLdouble, GLdouble);
Matrix3f current_matrix(void):
Matrix3f mmmult(Matrix3f, Matrix3f);
Vector3f mvmult(Matrix3f, Vector3f);
#endif /* _DRAWPLANT_H_ */
尝试更改
Matrix3f current_matrix(void):
to
Matrix3f current_matrix(void);
请注意末尾的分号。
相关文章:
- 多成员Constexpr结构初始化
- 为什么用结构初始化数组需要指定结构名称
- 使用指定的初始值设定项聚合匿名结构初始化
- 不同的类或结构初始化方法之间的性能差异是什么?
- 如何在结构初始化中获取成员C++
- C++正确的结构初始化
- 使用大括号进行结构初始化
- 内部结构初始化不起作用 - C++
- 使用嵌套结构初始化并集
- 使用匿名结构初始化联合
- 结构初始化语法
- 结构初始化的 C++ 向量
- C++嵌套结构初始化和访问成员
- 结构初始化中的常量正确性
- 使用 C++ 中的自定义元素进行 Const 结构初始化
- 如何在结构C++初始化内置数组
- Visual C++ 模板类成员结构初始化语法糖
- C++结构初始化
- C 在结构初始化过程中带有内部阵列的奇怪错误
- 此C/C 的结构初始化器如何使用足够的字段工作