A customer's code is expecting to find an include file malloc.h
in one of the "usual suspect" locations. On my Mac, AFAICT, there is no malloc.h
, at least not in any place you would expect to find it, such as /usr/include
, /usr/local/include
, or /opt/local/include
. Since the malloc()
is usually defined in stdlib.h
, and since the code includes stdlib.h anyway, I was able to get the code to build by just commenting out the few includes of malloc.h
. I am building with gcc
.
But two questions: Is my gcc messed up somehow? Should that file be there? Also, the code bombs almost immediately with a seg fault that I haven't been able to track down yet. Could this be the consequence of using the wrong malloc()
?
The malloc.h
is deprecated and should not be used. It contains some non-standard functions too. If you want to use malloc
, then include stdlib.h
. Not even the C89 standard mentions malloc.h
If it's the cause of your problems, I don't know, but it's quite probable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With