I'm putting my Simplicity Studio project into TortoiseSVN. I've been told to create an inc (includes) folder and use it. What is it? Why would I use it?
-
Some project structures use it to hold the header files. – Eugene Sh. Jun 03 '19 at 20:35
-
It is perhaps a matter of opinion, but in most cases is bad or at least unnecessary advice - although in this case seems to be a directive rather then advice. Sounds like a local coding practice, so you need to ask whoever is enforcing this practice to justify it. – Clifford Jun 03 '19 at 23:15
2 Answers
It's just a convention, not something that is required. For large projects it is often used to hold any file that is included from another file, i.e.:
#include "headerFile.h"

- 1,624
- 11
- 13
-
-
You don’t really need a header if the information in it is only going to be used in one source file. Headers are inherently intended for sharing information between source files. – Jonathan Leffler Jun 04 '19 at 00:08
You might ask the person who "told" you to do that - it is not a language or tool-chain requirement.
The preprocessor does not care where the include files are so long is you tell it (either in the #include
directive itself, by command line options or environment variables). Putting all headers in a folder separate to the associated .c files is a common practice but often a habit rather than for any good reason. It is useful when the headers relate to some static, shared library, or DLL where the headers are to be distributed with the compiled object code.
In other cases it is arguably simpler and more useful to keep the headers and the associated .c files in the same directory as each other. That allows for example "localised" headers to be included using double-quotes without needing to explicitly tell the preprocessor which paths to search.

- 88,407
- 13
- 85
- 165