Sign in to follow this  

File Dependencies

Recommended Posts

Gink    100
What is the point of minimizing dependencies between files? Ive read that you only have to change one file thats part of a group instead of just one file, but if you change one files implementation then it all needs to be recompiled anyway, right? Then what is the point of Dividing files into things like User interface,Programmer interface, interface implementation, etc? I dont see how it reduces compile time, maybe because im using an IDE to do all the work or maybe because none of the programming books explained it. Also, is there a guide on manually compiling without the IDE using the Dev-CPP Compiler? All their help file says is "How to press f9 to compile a file" which is obvious, but I cant find any documentation on how to use their compiler / the help feature is disabled on it.

Share this post

Link to post
Share on other sites
Conner McCloud    1135
When you compile a program, all function calls [that don't get inlined] end up as just links to some function that'll be found elsewhere. Then the linker comes around, and matches those links with the actual function definitions, so that everything works out when the program is run.

The important thing here is that changing the function's code doesn't change that link. So long as the prototype remains the same, the calling code doesn't need to be recompiled for the linker to make everything work properly.

So that is why keeping actual code out of header files speeds up compilation. Unless you change the header itself, the files that include that header will never need recompiled. The links never change, and so all the related code is still valid. Conversely, if you combine both, then the dependency checker can't tell if you've changed a function declaration [which defines those links], or the definition. So it has no choice but to recompile everything just in case.

That's also why you can compile programs with missing functions so long as they never get called - the linker doesn't see any links to the function, so it has no reason to care that the code itself is missing.

For your other question, DevCPP uses mingw, which is a windows implementation of gcc. Look for stuff about compiling with gcc, and you should be able to adapt it to mingw easily enough.


Share this post

Link to post
Share on other sites
nihilisticod    204
When you change one file's implementation, everything else does not usually need to be recompiled, just relinked. It is possible that your compiler just recompiles everything anyways though.

Dividing files into categories modularizes your project according to the idea that good software has high cohesion and low coupling between modules. First, in a large enough project with many developers, there must be some qualatative organization to a project or managing it will become a nightmare. Sometimes. a software project will actually keep the source for different modules entirely seperate, sharing interface and datatype files only. Each module would then be built into a lib and linked together. A change to one module requires recompilation for that part only. Then the project is relinked. It is a very organized way to develop.

With a game, the final product is usually very different from original designs. With the internals being constantly modified and tweaked (often drastically) this technique seems like it would bring with it more overhead than it is worth in hobby games. Enterprise software would have very specific requirement specifications, and therefore, once a particular module works and is thorougly unit-tested, only minor changes would be made to ensure proper interaction with other modules.

Since high-performance is critical in games, you end up with a lot of modules with very high coupling, which makes things harder to organize. Also, many compilers have options for full project optimization, which cannot be done if you compile into seperate objects and then link manually. I'm don't know if there is much benefit to this optimization though.

And as conner said, look up compiler info for gcc

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this