What does #include actually do?

That (copy/paste) is exactly what #include "header.h" does.

Note that it will be different for #include <header.h> or when the compiler can't find the file "header.h" and it tries to #include <header.h> instead.


Logically, that copy/paste is exactly what happens. I'm afraid there isn't any more to it. You don't need the ;, though.

Your specific example is covered by the spec, section 6.10.2 Source file inclusion, paragraph 3:

A preprocessing directive of the form

# include "q-char-sequence" new-line

causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the " delimiters.

Tags:

C

Include