makefile - Tips/resources for structuring C code? -


does have tips/resources how to, in best way, structure c code projects? (different folders etc.) , how know when it's split code separate files? , example of makefile?

my project not big, wanna start structure code @ stage..

structuring code needs experience common sense.

for splitting code, go readability: conceptually coherent functions/datatypes should go in same file. can take c standard library example. better keep data structure definitions , function declarations in separate headers. allows use data structures part of compilation unit if have not defined functions.

files provide similar functionality should go in same directory. avoid deep directory structure (1 level deep best) complicates building project unnecessarily.

i think makefiles ok small projects, become unwieldy bigger ones. serious work (if want distribute code, create installer etc) may want @ cmake, scons, etc.

have @ gnu coding standards: http://www.gnu.org/prep/standards/standards.html

look @ gnu make manual simple example makefile. can pick opensource project , @ makefile. browsing code repositories in sourceforge.net may useful.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -