I have been looking at various open source projects, and they have a bunch of files written in C that have .inc
as a file extension. As far as I can tell, they are used like header files.
I thought the standard convention was to use .h
files for header files and .c
for source files. So, is there a standard convention on when a header file should be an .inc
file rather than being a .h
file, or are these decided only at a per project basis? (Or am I just looking at weird projects that use .inc
?)
The standard convention is to use .h
for header files that contain only macro definitions and other declarations and .c
for C source files that contain code and data definitions.
In some projects, code fragments are stored in separate files and included in C source files with some macro tricks to expand specifically in different files or circumstances. Sometimes, these files are even included multiple times in the same source file. To underscore the special semantics attached to such files, giving them a different extension may be a useful hint. These files may also have been generated as part of the build process: naming them specifically may prevent confusion with actual source files.
Look at the files you came across in these projects and verify if this explanation holds.