Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / GDK - including other .cpp files?

Author
Message
Hayer
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 23rd Nov 2007 13:12
HI
How can I have many files like:
func.cpp
cam.cpp
main.cpp

linked togheter, so the main loop in main.cpp can call other functions(or are they called subs? ) from func.cpp?

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 23rd Nov 2007 13:54
#include "func.cpp"

or, Solution Explorer > Source Files > Right Click > Add > Existing Item

"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers
Hayer
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 23rd Nov 2007 14:19 Edited at: 23rd Nov 2007 14:22
mh-m.. Don't seem to work, I'll try again.

edit:
nope, here is my top of the main.cpp


and here is how i call the sub/func whatever inside my main loop


and here is my test1.cpp file


IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Nov 2007 14:27
#include is for header files and inline templates, not for general source code.

Just right-click on your solution and select Add->New items (or whatever it says).

For example:
Cam.h


Cam.cpp


Then in any file that needs access to the 'PositionCamera' function, just include the Cam.h.

The benefits of arranging your code like this are:
1. Smaller source files are easier to understand (read the FPSC source if you think otherwise).
2. Changes to the Cam.cpp file mean that only that file needs to be recompiled before everything is linked together.
3. Better re-use - you can write a module and test it separately, then just paste a copy of the files into your main app when you are done without disturbing existing code.

There are other benefits too, but I'll stop here before it turns into a full-blown lesson

Utility plugins collection and
http://www.matrix1.demon.co.uk for older plug-ins and example code
Hayer
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 23rd Nov 2007 14:44

Login to post a reply

Server time is: 2024-11-16 20:31:42
Your offset time is: 2024-11-16 20:31:42