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 file?
What about includes that are used in practically every file (i.e. stdio.h)?
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With