We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello, Somebody here insists that all the program's definitions will be stored in one large header file that all C modules include, rather that keeping the declarations distributed among specific header files. That sounds pretty crappy to me - but how bad it is really? will it have a very negative impact on build time?
Build time is affected by a lot of factors.
Is your program large? Do you have a slow computer? Do you use maximum optimization? Do you regularly add global variables or change data types or function signatures, requiring all affected source files to be recompiled?
In my case, I have one header file that brings in all general stuff and then require other source files to include some module-specific headers - for example all code requiring SPI has to include a header file with the SPI transfer functions declared.
If I change my "general.h" file, every single C file in the project needs to be recompiled. But either my projects are too small, or my computer fast enough (I'm desperately waiting for a new one), but the build times are quite short.
However, I would not like to have everything in a single file because that file would be way too large and hard to handle. If your source files may only include one custom header file, that header file should then include new header files for the different modules and devices. Having a huge header file would also be bad for version control - yes, CVS et al can merge changes from multiple developers. However, the file will get a very long history of changes and I like to be able to quickly get an overview who has changed what and when. CVS annotate/Subversion blame would also produce a too long list to scan.
If we return back to the SPI stuff again. I have one spi header file dedicated to all the processor-specific constants (the Keil file only defines the device registers, not all the flags for each register) and a second header file with the names and data types of every symbol the SPI module export. The SPI implementation will require both header files, while other parts of the program will only need the header file with exported symbols, and their data types.