delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/06/13:03:35

Date: Sat, 6 Sep 1997 10:01:49 -0700 (PDT)
Message-Id: <199709061701.KAA07225@adit.ap.net>
Mime-Version: 1.0
To: Alexander Gottwald <Alexander DOT Gottwald AT informatik DOT tu-chemnitz DOT de>,
djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: DJGPP progs always crash
Cc: ago AT informatik DOT tu-chemnitz DOT de

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019