The impact of one huge header file

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?

Parents
  • I do agree with you on that!

    "will it have a very negative impact on build time?"

    If every source file depends on this one header file, then any change to the header will cause all the source files to be rebuilt - even if the changes have no effect on most of the modules.

    Thus, effectively, every build becomes a full build!

    Also, most tools do have some finite file size limit - so if the header is really huge, you might blow that limit...

    There might also be limits on the numbers of symbols that the compiler and/or preprocessor can cope with in a single "translation unit"...

    The biggest practical issue that I see is where there is more than 1 programmer on the team: if there is only 1 header file, then everyone will be constantly fighting to make their changes to the one file!

    The major objection, however, is a "philosophical" one:
    One of the underpinning principles of block-structured languages is the facility to isolate the "scope" of things to just the area of code where they are really relevant.

    In the jargon, modules should be "loosely coupled".

    Using 1 massive global header, of course, totally destroys this!

Reply
  • I do agree with you on that!

    "will it have a very negative impact on build time?"

    If every source file depends on this one header file, then any change to the header will cause all the source files to be rebuilt - even if the changes have no effect on most of the modules.

    Thus, effectively, every build becomes a full build!

    Also, most tools do have some finite file size limit - so if the header is really huge, you might blow that limit...

    There might also be limits on the numbers of symbols that the compiler and/or preprocessor can cope with in a single "translation unit"...

    The biggest practical issue that I see is where there is more than 1 programmer on the team: if there is only 1 header file, then everyone will be constantly fighting to make their changes to the one file!

    The major objection, however, is a "philosophical" one:
    One of the underpinning principles of block-structured languages is the facility to isolate the "scope" of things to just the area of code where they are really relevant.

    In the jargon, modules should be "loosely coupled".

    Using 1 massive global header, of course, totally destroys this!

Children
More questions in this forum