#include <malloc.h> -- Xcode

23,830

If you just need to use malloc then you can grab it from the stdlib like so:

#include <stdlib.h>

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

#include <malloc/malloc.h>

EDIT:

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

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

Perhaps you can make an alias to this and use it?

Share:
23,830
Ryan
Author by

Ryan

Updated on May 09, 2020

Comments

  • Ryan
    Ryan about 4 years

    I have an interesting problem where I can't include malloc.h in my project.

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

    Problem is I can't find the system library for memalign.

    Xcode keeps failing because it cannot this definition & neither can I.

    Anyone else seen this?!

  • Ryan
    Ryan about 13 years
    Its not malloc I need. Its memalign.
  • Ryan
    Ryan about 13 years
    Ive tried including both of the above & neither contains a prototype for memalign
  • KushalP
    KushalP about 13 years
    You could remap it to use posix_memalign. See my edit to the question.