[comp.sys.amiga.programmer] HEEELLLPPPPPP!!!!!

u895762@BRUNY.CC.UTAS.EDU.AU (Pavel Evgenjevich Sabourenkov) (06/06/91)

 Thanks everybody who send me some suggestions. I really appreciate it.

 The bug was in the manx itself - it did not know what type of variable 
malloc() returns, so it assumes it's an int, although the user manual says
it should return (char *).
 
 There is an easy way to fix it - include 

char *malloc();

 in the begining of the program.

-Happy programming.

-Paul S. u895762@bruny.cc.utas.edu.au

Only \\
      \X/ Amiga.

jdickson@jato.jpl.nasa.gov (Jeff Dickson) (06/07/91)

In article <9106060516.AA18295@bruny.cc.utas.edu.au> u895762@BRUNY.CC.UTAS.EDU.AU (Pavel Evgenjevich Sabourenkov) writes:
>
> Thanks everybody who send me some suggestions. I really appreciate it.
>
> The bug was in the manx itself - it did not know what type of variable 
>malloc() returns, so it assumes it's an int, although the user manual says
>it should return (char *).
> 
> There is an easy way to fix it - include 
>
>char *malloc();
>
> in the begining of the program.
>
>-Happy programming.
>
>-Paul S. u895762@bruny.cc.utas.edu.au
>
>Only \\
>      \X/ Amiga.

	That's not a bug! Did you include the file functions.h? Any function 
that isn't explicitly declared as returning a particular type of object 
defaults to returning an int. This is standard C practice!

	jeff

UH2@psuvm.psu.edu (Lee Sailer) (06/08/91)

> There is an easy way to fix it - include

>char *malloc();

> in the begining of the program.

Aaahhhh.  Of course.

Anyway, I've noticed that Borland C++ considers a function that
doesn't have a prototype to be an error.  Thus, this type of
programmer error (it isn't really a bug, in C Classic) cannot
occur.  It ought to be at least a warning, anyway.  I think
that the ANSI C standard requires it to be either an error or a warning.

lee

eoo@let.rug.nl (Eize Oosting) (06/10/91)

In article <9106060516.AA18295@bruny.cc.utas.edu.au> u895762@BRUNY.CC.UTAS.EDU.AU (Pavel Evgenjevich Sabourenkov) writes:
>
> Thanks everybody who send me some suggestions. I really appreciate it.
>
> The bug was in the manx itself - it did not know what type of variable 
>malloc() returns, so it assumes it's an int, although the user manual says
>it should return (char *).
> 
No, the BUG was in YOUR program. Although the user manual says that malloc()
returns a char *, it also says that you should include <stdlib.h> to let the
compiler know too, because the compiler does NOT know the user manual (this
last qoute is not my own inspirition, but someone else's).

By the way, malloc() returns a void *, not a char *.

> There is an easy way to fix it - include 
>
>char *malloc();
>
> in the begining of the program.
>

No, #include <stdlib.h> in the beginning of your program.
 
>-Happy programming.
>

Correct programming!!!!

  /\__________/\   /\___________________________________________________/\
 /              \ /                                                       \
|   Letteren-    |  Marvin Minsky once defined Artificial Intelligence as: |
|   Faculteit    |   '... the science of making machines do things that    |
| R.U. Groningen |   would require intelligence if done by men'.           |
| The Netherlands|                                                         |
|                |  Does this include adding a device to the Mountlist?    |
| eoo@let.rug.nl |                                           Eize Oosting  |
 \  __________  / \  ___________________________________________________  /
  \/          \/   \/                                                   \/