Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Different source files.

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
5 replies to this topic

#1 Dennisvb   Members   

160
Like
0Likes
Like

Posted 01 March 2013 - 02:44 PM

Hello,

I want to have my Init, Update, Draw and CleanUp functions all in different source files, so when the game gets larger I don't end up with long compiling times. Do I need to put every function in a different class, or do I create a class called for example Game and define the functions in different source files like this: Game::Init() etc.?
Thanks,
Have a nice day!

#2 Paradigm Shifter   Members   

5832
Like
0Likes
Like

Posted 01 March 2013 - 03:06 PM

You can put the function bodies for class member functions in separate source files as long as they all include the class definition (which would be in the header file).

 

Not sure if it will improve compile times though and it will probably prevent some optimisations (splitting the functions across different files, usually the optimiser only optimises each file individually), unless you use compile time linking, which slows down the compilation a lot...


Edited by Paradigm Shifter, 01 March 2013 - 03:07 PM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#3 Vortez   Members   

2713
Like
1Likes
Like

Posted 01 March 2013 - 10:43 PM

It should't matter if you put those functions all in the same file, in fact it will be faster since you'll only need to compile one file instead of four when doing a full rebuild or make change to more than one functions. Using four files for those function will probably add complexity to your project with no noticable benifits whatsoever, unless you're compiling with a 486 :P



#4 Dennisvb   Members   

160
Like
0Likes
Like

Posted 02 March 2013 - 12:48 AM


It should't matter if you put those functions all in the same file, in fact it will be faster since you'll only need to compile one file instead of four when doing a full rebuild or make change to more than one functions. Using four files for those function will probably add complexity to your project with no noticable benifits whatsoever, unless you're compiling with a 486 :P


Ha, thanks. I thought it would be quicker, but I will put those functions all in one class in one file ;).

#5 Vortez   Members   

2713
Like
3Likes
Like

Posted 02 March 2013 - 10:39 PM

Still, it's a good idea to put different class in different files, but for single functions, i would not recomend it.



#6 Dennisvb   Members   

160
Like
0Likes
Like

Posted 03 March 2013 - 12:25 AM


Still, it's a good idea to put different class in different files, but for single functions, i would not recomend it.

That is what I do now.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.