Is it a good idea to put all of your includes in one header file?

后端 未结 7 762
青春惊慌失措
青春惊慌失措 2021-01-04 21:08

What is the best practice for C what you put into a C header file?

Is it useful to put all the includes used for a program across multiple source files in one header

7条回答
  •  再見小時候
    2021-01-04 21:40

    Putting all possible headers in one application header is as wrong as wrong can be.

    This is laziness that comes at a great price. It makes builds brittle. It makes it hard to understand where true dependencies are, and thus hard to refactor or otherwise re-use code.

    It makes it hard to test.

    But the biggest problem is that it represents intellectual laziness and encourages more of the same.

    As will all programming issues, do what is needed, no more, no less. Think about maintainence. Think about build management.

    Just THINK.

提交回复
热议问题