Re: How to know if malloc.h is available?



On November 19, 2008 16:10, in comp.unix.programmer, Lew Pitcher
(lpitcher@xxxxxxxxxxxx) wrote:

On November 19, 2008 15:40, in comp.unix.programmer, fogli_beppe@xxxxxxxxx
(fogli_beppe@xxxxxxxxx) wrote:

Hi,
is there a way to know if the header file malloc.h is available?
[snip]
I have this piece of code:

#if defined (__sun) || defined (__i386) || defined (__ia64)
#include <malloc.h>
#define HAVE_MALLINFO
#endif

It compiles on linux (x86, x86_64 and itanium) and on Solaris (SPARC)
but it doesn't compile on Mac OS X (x86), where the compiler (gcc from
XCode 3.1.1) can't find malloc.h .

Well, that's the cannonical test for whether or not malloc.h is available
to the compiler.

Now, two things:
1) For the compiler to be /complete/, it /must/ include a malloc.h header.
So, go back and check the install for the compiler to see if it missed
something.

Oops... let me correct that.
For the compiler to be complete, it must include malloc() and friends. The
header for the malloc() family of functions is <stdlib.h>, not <malloc.h>.

--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------


.



Relevant Pages

  • Re: Use of C99 int types
    ... > those that actually are part of the C-implementation for Linux. ... the kernel definitions are part of /usr/include). ... The kernel uses __foobar stuff provided by the compiler because it has ... > the Gimp and GCC run on completely different architectures aswell. ...
    (Linux-Kernel)
  • Re: censored by comp.compilers [was please suggest an OS and language a text]
    ... z/OS has way more hardware capability than Intel ... Linux has basically no doc except what people feel ... than simple file I/O to write a compiler, ...
    (comp.lang.misc)
  • Re: censored by comp.compilers [was please suggest an OS and language a text]
    ... The x86 instruction set isn't that complex, ... Windows has a lot of doc but Windows doesn't do 10% of what ... a static compiler can probably be done with little more than file IO. ... a VM involving JIT may need a bit more to be effective (mmap and libdl on Linux, ...
    (comp.lang.misc)
  • Re: function pointers
    ... I am using gcc under ... gdb, and the compiler, exactly like in 1986 when I first started using ... when running on linux, I usually use gedit or kedit. ... There is only one debugger: ...
    (comp.lang.c)
  • Re: 1] UNIX/LINUX Compilation 2] IDE
    ... under Unix or Linux? ... compiler, and Josh Vanderhoof's Cross ELF linker. ... AFAICT, RHIDE is the only ... VIM is in some ways as good as GNU Emacs ...
    (comp.os.msdos.djgpp)