#include <malloc.h> - Xcode

I have an interesting problem when I cannot include malloc.h in my project.

I need malloc.h for the Paul Nettle mmgr tool (I'm not keen on using tools)

The problem is that I cannot find the system library for memalign.

Xcode continues to fail because it cannot define this, and I cannot either.

Has anyone else seen this ?!

+6
source share
1 answer

If you just need to use malloc , you can take it from stdlib like this:

 #include <stdlib.h> 

Otherwise, you can directly call malloc.h like this:

 #include <malloc/malloc.h> 

EDIT:

A posix_memalign() exists in stdlib.h . The implementation looks like this:

 int posix_memalign(void **, size_t, size_t); 

Perhaps you can make an alias and use it?

+21
source

Source: https://habr.com/ru/post/887570/


All Articles