Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
stevenhaggerty
Posts: 30
Registered: ‎03-03-2012
My Device: Playbook
My Carrier: Blackberry
Accepted Solution

QCC compilation oddness.

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.

 

 

 

 

-------------------------------------------------------------
Steven Haggerty,
Rubicon Development ( http://www.rubicondev.com/ )
Please use plain text.
Developer
papabob500
Posts: 19
Registered: ‎03-04-2012
My Device: Playbook 2.0
My Carrier: Vodafone

Re: QCC compilation oddness.

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. 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: QCC compilation oddness.

[ Edited ]

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

Please use plain text.
Contributor
stevenhaggerty
Posts: 30
Registered: ‎03-03-2012
My Device: Playbook
My Carrier: Blackberry

Re: QCC compilation oddness.

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.

 

-------------------------------------------------------------
Steven Haggerty,
Rubicon Development ( http://www.rubicondev.com/ )
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: QCC compilation oddness.

[ Edited ]

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 :smileyhappy:

 

Cheers,

Sean

Please use plain text.
Contributor
stevenhaggerty
Posts: 30
Registered: ‎03-03-2012
My Device: Playbook
My Carrier: Blackberry

Re: QCC compilation oddness.

Hi Sean, I'm not much of a Linux/Eclipse guy, could you spell that out in an absolute file location (or as near as possible).

Thanks,

Steve.
-------------------------------------------------------------
Steven Haggerty,
Rubicon Development ( http://www.rubicondev.com/ )
Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 660
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: QCC compilation oddness.

On my mac, it's $(WHEREVER_THE_NDK_WAS_INSTALLED)/target/qnx6/usr/include/mk/qmacros.mk and rules.mk

Please use plain text.
BlackBerry Technical Advisor (Retired)
davidcummings
Posts: 20
Registered: ‎10-27-2010
My Device: Bold 9800

Re: QCC compilation oddness.

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

Please use plain text.