Search code examples
clinkerobject-files

is header file path reference in .c file included in object file (.o)


I compile an example.c file that has the line:

#include "parse/properties/properties.h"

The compiler creates get an example.o file. Is the path to the header file included in the example.o file? or is that information external?


Solution

  • It may or may not, the object file format is not standardised (the standard does not even mention "object files"). A compiler might insert the #include for debugging purposes, or it may skip it completely.

    Note also that #include'ing is done by the compiler in what the standard desrcibes as the first phase in translation, using a textual preprocessor; the #include-directive tells the preprocessor to copy verbatim and inplace the contents of another file. This happens long before actual object files would be produced