I can't figure out what the actual problem is with this.
typedef struct _actor
{
...
} _actor, Actor;
class Actor
{
...
};
I get this weird error message actor.cpp:31: error: using typedef-name ‘Actor’ after ‘class’
.
Any idea what I did wrong here? Thank you :)
for arduino hectop 3d printer:
Rename
fpos_t
variables inSdBaseFile.h
andSdBaseFile.cpp
to another name likefpos_t1
and recompile.You are not allowed to define the symbol
Actor
more than once. Thetypedef
statement already defines the symbolActor
as an alias forstruct _actor
before you attempt to declare a class with the same name.I'm guessing you're using the
gcc
compiler. I get the following errors when I compile withgcc
:The first message (pointing the
class Actor
line in the program) states that you cannot declare a class with atypedef-name
(Actor
is already declared usingtypedef
). The second message (pointing to thetypedef struct _actor
line in the program) is a little clearer and refers to the multiple declarations forActor
.It is very common in C/C++ for a single class of error like this to result in multiple compiler errors and often the more helpful message is not the first reported.
To understand what going on, we need to break the first statement up into it's parts:
First we create a structure called
_actor
. Next, we create a typedef forstruct _actor
called_actor
. This is only useful in C. It allows us to say:instead of
But in C++, it's unnecessary, as C++ allows us to use the first form natively, without the typedef.
The third line creates a second typedef for
struct _actor
calledActor
. When you then try to create a class namedActor
the compiler complains, as that name is already being used for the alias for the struct.Now, it seems likely that in the original C code, the author had intended
struct _actor
to be merely an implementation detail, and that you would always use justActor
to refer to instances of this struct. Therefore, in your C++ code, you should probably eliminate the typedefs entirely, and just rename the struct. However, that will give you:So, prehaps you should look into merging those two classes.