Ryan
Ryan

Reputation: 877

#include <malloc.h> -- Xcode

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?!

Upvotes: 7

Views: 24717

Answers (1)

KushalP
KushalP

Reputation: 11206

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?

Upvotes: 25

Related Questions