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
Highlighted
Contributor
Posts: 26
Registered: ‎06-27-2012
My Device: Playbook
My Carrier: n/a
Accepted Solution

How do you define preprocessor directives?

I've tried defining preprocessor directives everywhere I can define a custom variable in the project settings... to no avail. Is this even possible? Why is such a basic operation so difficult to do in Momentics?

 

Under a regular Eclipse C++ environment, I belive this is set in C/C++ Build/Settings, but this area is completely different in Momentics.

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How do you define preprocessor directives?

give us an example - what preprocessor directive do you want to define?

Contributor
Posts: 26
Registered: ‎06-27-2012
My Device: Playbook
My Carrier: n/a

Re: How do you define preprocessor directives?

Custom ones for temporary conditional compilation. For example, in a CPP file I want to be able to do something like this:

 

#ifdef PHASE1

.. some C++ code here

#else

.. some other C++ code here

#endif

 

Then I want to define PHASE1 in a project configuration so that the correct code is compiled.

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How do you define preprocessor directives?

Project right-click Properties->C/C++ Build->Settings->QCC Compiler->Preprocessor->Defines (-D)

Contributor
Posts: 26
Registered: ‎06-27-2012
My Device: Playbook
My Carrier: n/a

Re: How do you define preprocessor directives?

My Momentics IDE with BB 10.0.4 does not have any "QCC Compiler" tab or section. The top portion shows the selected configuration. The bottom portion has three tabs which are "General Settings", "Binary Parsers" and "Error Parsers."

 

Is this the same as the environment that you are using?

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How do you define preprocessor directives?

Sorry, I am using NDK 2.0

Developer
Posts: 43
Registered: ‎06-30-2012
My Device: Bold 9900
My Carrier: T-Mobile

Re: How do you define preprocessor directives?

I have spent the better part of an hour also trying to figure out how to get the preprocessor to create and KEEP the .i and .ii files so I can see the result of my #defines.....UGH!!

 

(also on 10.0.4)

Retired
Posts: 60
Registered: ‎05-10-2012
My Device: Blackberry 10 Alpha
My Carrier: none

Re: How do you define preprocessor directives?

Hello, I'm not sure if you're using a make or .pro file but you can  add it to either one using the

 

-D{PREPROCESSORNAME} option. For example -DUSEOPENSSL.

 

For example with a .pro file you would add

 

QMAKE_CXXFLAGS += -DUSEOPENSSL

 

clean and rebuild afterwards

 

Cheers

Selom

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: How do you define preprocessor directives?

I guess the question was about where to specify this in IDE

Contributor
Posts: 26
Registered: ‎06-27-2012
My Device: Playbook
My Carrier: n/a

Re: How do you define preprocessor directives?

Thanks selom!

 

Since this is defined in the .pro file, is it possible to set up two configurations and have each configuration use a different .pro file?