Mail Archives: djgpp/2000/07/16/08:48:08
In article <8ks68a$8ht$1 AT newsflood DOT tokyo DOT att DOT ne DOT jp>,
Dan and Shelly <wedeking AT msa DOT attmil DOT ne DOT jp> wrote:
>I found out that I needed to download and extract the gcc program. So I did
>that and tried the hello world program again using rhide. I typed in:
>
>#include
>int main()
>{
>printf("Hello world!\n");
>exit(0);
>}
>
>
>But now when I try to run the above program in rhide, I get the error
>message that the #include is expecting a file name after it. Did I
>forget to download something else beside the gcc program?
Not at all. You've told the compiler "before you compile this program,
include a file which tells you where to find, for example, printf". But
then you haven't told it what file to include.
All of the standard functions - printf, alloc, all that stuff - are
"linked" with the program when you compile it. But unless you tell the
compiler "don't worry: you'll find this function later on in the standard
function library" it gets confused.
What you want is "#include <stdio.h>" . If you ever use a function that
isn't one of your /own/ (like printf) then you need to include a header
file. Try typing looking up the help on printf: it will tell you what you
need to include. Now try looking up the help on, say, alloc. It will tell
you you need to include <alloc.h> (or is it <malloc.h>?)
The header (".h") files give function "declarations" ("I might be using
THIS function, Mr Compiler). The library gives function "definitions"
("This is what the function looks like and does, Mr Compiler") and so is
only linked with your program when you actually want to create a .exe
file. The standard library is linked automatically: things like the maths
libraries aren't.
The declarations tell the compiler immediately that printf(3) is illegal,
whereas printf("Hello, World!\n") isn't. The definitions tell the compiler
what printf actually does.
J-P
- Raw text -