Other Parts Discussed in Thread: MOTORWARE
I am using the last released MotorWare version: 01_01_00_11 and the compiler version 6.2.3, but had that same behaviour at earlier versions of both already. In our project we use C++, so the C++ compiler is used.
In many modules inside the MotorWare, there are these so called “handles” defined. There is always an object defined as a struct with typedef and then there is a handle defined, which is a pointer to that struct. It’s the same construction in many modules.
When I compile these files, I do always get a compiler error. Below is an example from the file clarke.h, but it’s the same for all other files.
//! \brief Defines the CLARKE object
//!
typedef struct _CLARKE_Obj_
{
_iq alpha_sf; //!< the scale factor for the alpha component
_iq beta_sf; //!< the scale factor for the beta component
uint_least8_t numSensors; //!< the number of sensors
} CLARKE_Obj;
//! \brief Defines the CLARKE handle
//!
typedef struct CLARKE_Obj *CLARKE_Handle;
When I try to compile this, I get the following error message:
…/sw/modules/clarke/src/32b/clarke.h", line 86: error #1277: typedef "CLARKE_Obj" may not be used in an elaborated type specifier
It seems like the compiler doesn’t like it, when using the typedef name CLARKE_Obj for another typedef struct.
I found 2 different workarounds, both are fine and everything works, the first is to omit the second “struct” like this:
//! \brief Defines the CLARKE handle
//!
typedef CLARKE_Obj *CLARKE_Handle;
The second workaround is to use the above defined typedef name with the underscores:
//! \brief Defines the CLARKE handle
//!
typedef struct _CLARKE_Obj_ *CLARKE_Handle;
I can compile the MotorWare on the testlabs without an error, but not in our project, maybe it’s because we are compiling in C++ and that compiler is more strict. I also tried to compile the labs with the setting --cpp_default and get the same error.
Is it possible to change these handle definitions in the MotorWare in order to compile them using C++? Or did I forget any necessary setting to avoid these compiler errors?