0

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?

Posva
  • 1,104
  • 9
  • 15
  • You're using a [reserved identifier](http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier). – chris May 04 '14 at 16:05
  • You missed a '#' from animation.cpp And a 'l' (lowercase L) from torse.hpp under the class definition, change 'pubic' to 'public' – Dávid Szabó May 04 '14 at 16:07
  • Where is `Renderable` defined ? `Torse` is inheriting from it but I see no include. – Chnossos May 04 '14 at 16:08
  • DO you mean the `me`? – Posva May 04 '14 at 16:08
  • @newboyhun these are actually errors from the copy paste but thank you for pointing it out – Posva May 04 '14 at 16:09
  • @Chnossos it is included as well, there's no problem with that one – Posva May 04 '14 at 16:10
  • 2
    @Posva ok, but now I see you defined a classe `Torse` and then you use `torse` in your animation functions ... – Chnossos May 04 '14 at 16:12
  • @Chnossos Oh god, that was so stupid, as always... Thank you very much. I'm used to have Uppercase files and we don't in this project... Also clang usually points out this kind of errors with something like "Didn't you mean ..." – Posva May 04 '14 at 16:14

1 Answers1

2

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

Fix your case.

Chnossos
  • 9,971
  • 4
  • 28
  • 40