[英]aggregate ‘arcball arcball’ has incomplete type and cannot be defined
我对以下文件有问题:
我在此文件上有arcball结构:
#ifndef ARCBALL_H_
#define ARCBALL_H_
#include "ex1.h"
...
extern struct arcball{
float radius;
int x,y;
}arcball;
...
#endif /* ARCBALL_H_ */
并且我有以下包含arcball.h文件的ex1.h文件:
#ifndef __EX1_H__
#define __EX1_H__
////////////////////////////
// Project Includes
////////////////////////////
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include "arcball.h"
////////////////////////////
// OpenMesh Includes
////////////////////////////
#include "OpenMesh/Core/IO/MeshIO.hh"
#include "OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh"
////////////////////////////
// GL Includes
////////////////////////////
#include "GLee.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
...
struct arcball arcball;
#endif
我必须包括ex1.h标头,因为ex1.h包含了我在arcball.cpp文件中使用的glut函数。 并且我必须使用arcball.h标头才能使用该文件上的函数和struct定义。
我得到的错误如下:
In file included from arcball.h:11:0,
from arcball.cpp:8:
ex1.h:120:16: error: aggregate ‘arcball arcball’ has incomplete type and cannot be defined
make: *** [ex1] Error 1
我不明白为什么它是不完整的类型,因为我包含了arcball.h文件
这是互斥问题还是结构定义/使用问题? 以及如何解决?
谢谢!
这两个.h
文件相互包含,引起很多混乱。 这是一个非常糟糕的主意,因为周围的#ifdef
会根据首先包含哪个文件而产生不同的效果:在这种情况下,arcball.h-> ex1.h-> arcball.h-但实际上并没有-因为-#ifdef。
此外,在头文件(此处为ex1.h)中声明没有extern
的变量也是一个坏主意。 那可能并没有您想要的效果。 没有extern
变量只能在.c
文件中声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.