Posva
Posva

Reputation: 1102

C++ member access into incomplete type although header is included

I'm running into a strange problem using forwards declarations. Here is the code:

The Torse class, torse.hpp

#ifndef _TORSE_
#define _TORSE_

class Animation;
enum frame_type;

class Torse : public Renderable
{
public:
const glm::vec3& getCurrentRotation(frame_type);
};
#endif

in torse.cpp:

#include "torse.hpp"
#include "animation.hpp"
const glm::vec3& Torse::getCurrentRotation(frame_type t)
{...}

Now in Animation class, animation.hpp

#ifndef __ANIMATION_H__
#define __ANIMATION_H__

class torse;

class frame {...};
class Animation {

public:
void generateInterpolation(torse& me);
};
#endif

in animation.cpp:

#include "animation.hpp"
#include "torse.hpp"
void Animation::generateInterpolation(torse &me)
{
...
f1.rot[j] = me.getCurrentRotation(f1.type)[j];
...
}

As you can see I'm sharing the enum frame_type and the classes Anmation and Torse But I feel Like I'm doing it right, as in animation.cpp it should know how torse is thanks to torse.hpp...

clang gives me this error:

src/animation.cpp:19:43: error: member access into incomplete type 'torse'
                            f1.rot[j] = me.getCurrentRotation(f1.type)[j];
                                        ^

Anyone have a clue?

Upvotes: 0

Views: 5869

Answers (1)

Chnossos
Chnossos

Reputation: 10456

You defined a type Torse, but clang complains about a type named torse.

Fix your case.

Upvotes: 2

Related Questions