Mail Archives: djgpp/1997/09/06/13:03:35
At 01:07 9/5/1997 +0200, Alexander Gottwald wrote:
>Hello
>
>some weeks ago i installed DJGPP. But nearly every program I compiled
>crashed with an General Protection fault. Some small worked well. I
>think I may have problems with pointers. Is there a compiler switch
>which I have to use? Alegro compiled fine (with the makefile) an even
>the examples worked. But a little program which was using alegro crashed
>inside putpixel, where a pointer was used.
>
>Even the testprogram farptr.c
> [farptr.c was MIME-encoded and contained this line:]
>int
>main(long l, short s, char c)
That's your problem. main can only be declared like this:
int
main(int argc, char *argv[])
or like this:
int
main(void)
argc is set to the number of command line arguments your program got. argv
is an array of pointers to the arguments themselves. You'll have to use
something like atoi() or strtol() to get the numbers from the strings.
Perhaps you should consider getting a book on C.
Btw, please don't post files on this newsgroup as MIME-encoded. Your
mailer's "attach" feature probably did this. In this case, it would have
been far preferable to just include the farptr.c file in the body of the
message, as text. All the other stuff was unnecessary, and it usually is.
Many people can't decode MIME format, and many others just don't bother.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -