03-05-2012 11:47 AM
Hi there,
I'm trying to compile some code that compiles fine on iOS/PC/Android and fails with QCC in the IDE.
If I try the following:
typedef struct tPOINT
{
tINT Xc;
tINT Yc;
tPOINT (){};
tPOINT (tINT x,tINT y){Xc=x;Yc=y;}
tVOID Set (tINT x,tINT y){Xc=x;Yc=y;}
} tPOINT;
I get:
/media/OSDisk/Dev/Raz0r/Source/Raz0r.H:608: error: expected specifier-qualifier-list before 'tPOINT'
(The constructor line)
I've got a whole stack of other errors including one for every class in my header files (even if its a forward declaration)
class RZFile;
error: expected '=', ',', ';', 'asm' or '__attribute__' before RZFile
Is this due to qcc thinking my .H (capital H) files should be compiled as C rather than C++?
If so how to I change the compiler to recognise .CPP and .H files as C++?
Many thanks,
Steve.
Solved! Go to Solution.
03-05-2012 12:21 PM
I don't know if this is the case, but I've worked with some (propietary) compilers for embedded systems that are specially picky with the syntax (more if they are pure C rather C++ compilers).
Just a guess, but maybe it is confused by seeing the same id after the "typedef struct" and in the type name (like trying to do a "typedef struct MyStruct MyStruct;" without defining MyStruct earlier). You can try changing one of the id to something like tPOINT2 and see if the error is the same.
03-05-2012 12:58 PM - edited 03-05-2012 01:00 PM
I get the exact same error if I try to compile that code using gcc. Works with g++ though.
Try renaming to .cpp or .cc to be sure the c++ compiler is invoked.
FYI, qcc is essentially a wrapper for the gnu compiler toolchain.
Cheers,
Sean
03-05-2012 01:01 PM
Thanks for the reply. This is a shared codebase with hundreds of files, so changing all instances of the code is not really an option. Thanks for replying though!
It was as I though, the compiler doesn't seem to pickup on .CPP and .H being C++ files, so I jammed "-lang-c++" into the compiler options and it seems to at least compile now.
Thanks,
Steve.
03-05-2012 01:05 PM - edited 03-05-2012 01:07 PM
Poke around in target/qnx6/usr/include/mk.
qmacros.mk and rules.mk may be of interest to you.
Also, .h files are not compilable, so there are no rules for such things. They only get included into other files being compiled ![]()
Cheers,
Sean
03-05-2012 01:09 PM
03-05-2012 01:11 PM
On my mac, it's $(WHEREVER_THE_NDK_WAS_INSTALLED)/target/qnx6/usr/
03-05-2012 02:35 PM
You might also have some success adding *.CPP and *.H to the C file types preference page in the IDE located under Window->Preferences->C/C++->File Types