|
From: <or...@vp...> - 2003-09-20 00:50:58
|
André Macário Barros wrote: > In C codes, some functions don´t need the > respective #include header file command, like > printf, system(blah...), etc. They DO need the headers. Use the -Wall flag to see what happens, if you don't use the header. It will tell you something like: prog.c:11: warning: implicit declaration of function `printf' That is, printf is implicitly declared by the call to it. Now you probably wonder: "OK, that's fine, but shouldn't there be some linker error?" The question is right, there should be. But as far as I know, gcc (more accurately: mingw, dunno about other OSes) automatically links with a few system libs. Like "g++" is actually "gcc ... -lstdc++", so g++ automatically links with -lstdc++. Like this, gcc (mingw) links with -lm for example, and some other libs. But anyhow, you should ALWAYS include the respective header file for the function to make portable code. Use -Wall to see if you missed something. -- Greetings, Balázs |