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

后端 未结 7 761
青春惊慌失措
青春惊慌失措 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:41

    No. It simply adds cruft and overhead.

    One of the biggest pains that you'll face as a maintainer is figuring out what headers don't need to be included and get rid of them. Whe you get to a list of 20+ headers, you start contemplating ugly things like brute forcing through it (removing one at a time and seeing if anything breaks).

    Be kind to people who have to maintain your stuff in the future. Use the headers you need per module, no more .. no less :)

    0 讨论(0)
提交回复
热议问题