As far as I understand when we include stdio.h
the entire file is copied into the text of our program.(basically we prepend it) Then when we do a function call for printf()
why does it have to be linked first?
Is it that stdio.h
contains just the definitions of those functions and the compiler finds the compiled executable object file for the function that we invoke for example printf()
.
I've read about this in a few places but still kinda not clear.
CodePudding user response:
Header files like stdio.h generally just contain a declaration that defines the name of the function, the types of its arguments, and its return value. This is enough for the compiler to generate calls to the function, but it is not a definition. The actual code that implements the function is going to be in a library (with an extension like .a
or .o
or .lib
).