What I want to know is how a compiler and program work.
For example, in 'Hello, world!' example with, say, hello.c, it goes like this as everybody knows: (using GNU gcc)
$ gcc -o hello hello.c
$ ./hello
Hello world!
I just got a question how printf
, one of the easiest and familiar function, is defined or used.
To find a answer by myself, I found whole header files included in stdio.h, and included in included one, included in included in included one. There are almost 80 header files included in stdio.h. And I look for every single file whether it contain the word 'printf'. There were 3 header files.
stdio.h (itself)
bits/stdio2.h
bits/stdio-ldbl.h
I don't know about pre-processor syntax fully, but I'm quite sure that the text in those files are not enough to define the printf
function. For example, in stdio.h, printf is roughly referred like this:
...
namespace std{
...
extern int printf (const char *__restrict__format, ...);
...
}
...
I know it says syntax and kind of declaration, but I think it is not a definition or building of printf
.
So I think that there is something deep inside to answer my question, and I hope some of you have one.