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
Developer
Philipk
Posts: 676
Registered: ‎05-06-2012
My Device: Dev Alpha & PlayBook
My Carrier: wifi

Simple Include

This might be an obvious question but I've never written C/C++ untill recently.

 

In my 'src' folder I have a file called recordvideo.c

 

I want to include that in the main cpp file I had assumed I would do something like ...

 

#include<recordvideo.c>

 

Can anyone tell me how to properly include the c file? Also when you use #include what is the default path, e.g. in what folder is it looking for recordvideo.c?

_________________________________________________________
co-founder of Diaree | BB Dev for PictureThis
Please use plain text.
Developer
Developer
CMY
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
My Carrier: Verizon

Re: Simple Include

You don't include the source (c/cpp) files. They are compiled into the app binary. Header files (h/hpp) are the only ones that need to be included.
Please use plain text.
BlackBerry Development Advisor (Retired)
kizkasen
Posts: 54
Registered: ‎06-26-2012
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Simple Include

Thank you for the question.
You don't use the "#include" directive for .c files visibility, instead you use it to expose C/C++ types, classes, macros,...
i.e. your declarations located in your .h files to other .c/c++ files.
If you want your objects or global variables from your C/C+ files to be accessed by other C/C++ files, you can simply use the "extern" keywork (there are other ways to do that but this is the simplest way)

Please check our helloword application or the very basic apps for how to set your include path.
http://developer.blackberry.com/cascades/downloads/
http://developer.blackberry.com/cascades/documentation/dev/

http://developer.blackberry.com/cascades/documentation/getting_started/setting_up.html

Please use plain text.
Developer
jalue
Posts: 196
Registered: ‎03-04-2013
My Device: BB Z10
My Carrier: Rogers

Re: Simple Include

In addition...

 

When the include statement is:

 

#include <bb/cascades/QmlDocument>

 The compiler will look through the folders contained in the Include Path.. This is located in QNX Momentics IDE at:

Project -> Properties -> C/C++ General -> Paths and Symbols -> Includes tab on the right... The compiler will look through the folders contained there in the order they are in from top to bottom.

 

When the include statement is:

 

#include "Box2D/Box2D.h"

 

The compiler will look for the file relative to the current file that the include statement is in.  That is, in the same folder that the current file is in... 

 

.../workspace/NDK/myApp.cpp <--- include statement "" it will look in .../workspace/NDK/ ...

Please use plain text.