You are not logged in.
I'm new to programming, and I'm curious about the definitions of standard library functions like getchar(), but when I look in stdio.h, all I see are function prototypes. Where is the actual definition? Is it built into the compiler?
Thanks for your help.
Last edited by nbtrap (2012-02-21 17:24:31)
Offline
That would be in stdio.c, stdio.h is the header file.
Offline
Odds are you don't have stdio.c. You will have stdio.so (or something similar) which is the compiled object file resulting from stdio.c.
Read up on linkers if you wish to learn more about this. There was a great web-book linked in another recent discussion on the programming sub-forum specifically on compilers and linkers.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
That would be in stdio.c, stdio.h is the header file.
Thank you, I think I understand now. Correct me if I'm wrong: stdio.c is source code for glibc, which is compiled into a shared object file that is distributed with the glibc package. My only question would then be: how does the compiler know to link to the object file when it's not explicitly stated. For example when I compile a program, why do I not have to type:
gcc program.c /usr/lib/libc.so
and why does
gcc program.c
suffice?
Offline
Everything always gets linked to libc implicitly, unless you tell it otherwise by using `-nostdlib`.
Offline