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 / Multiple CPP files in a single project?

Author
Message
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 16th Apr 2008 17:23
Using visual C++ 2008 express edition I'm trying to have multiple CPP files in a single project. I'll explain exactly what I'm trying to do.

The 'DarkGDK' procedure held in a CPP file called 'main.cpp' which calls several functions which are held in a separate CPP file called 'functions.cpp'.

How can I get this to work?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 16th Apr 2008 17:27 Edited at: 16th Apr 2008 17:28
Create a header file containing the prototypes of those functions, and #include this in source files you want to call the functions from. Example:

otherfile.h


otherfile.cpp


After #including otherfile.h in main.cpp you can then call MyFunction.

jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 16th Apr 2008 17:57 Edited at: 16th Apr 2008 17:58
To add the source to the project ...
...In the Solution Explorer tab, there is a folder called Source Files. Right click that, select Add, Add existing item and navigate to the source file that you want to add. Do the same for the include file using the Header Files folder.

Be aware that you must either disable precompiled headers for that source, or add the line "#include "stdafx.h" if you are using precompiled headers. I'm not sure if GDK uses them.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 21st Apr 2008 20:24
I know I was sometimes WAY OFF in the networking thing - (never really did the udp thing yet - but that's a favorite thread of mine now)

And I'm not sure - how much you have done yet with mixing multiple files into one project like the replies explain, but I personally have had a heck of a time (more than once) getting circular references to compile corectly.

Each include file I have has the #pragma once directive, and sometimes I have to put an empty class declaration high up in the code - so that two classes are arware of each other:



Login to post a reply

Server time is: 2024-11-20 07:32:07
Your offset time is: 2024-11-20 07:32:07