Riot: malloc.h not found on OS X

Created on 27 Jan 2015  Â·  12Comments  Â·  Source: RIOT-OS/RIOT

Using the native port on OS X with clang I get this error when using pthread:

/Users/noir/Desktop/RIOT/sys/posix/pthread/pthread.c:22:10: fatal error: 'malloc.h' file not found
#include <malloc.h>
         ^
1 error generated.
Mac OS X native

Most helpful comment

I don't have much experience with compatibility stuff like this. Is it correct to do something like:

#if defined(__MACH__)
#include <stdlib.h>
#else 
#include <malloc.h>

and should I do this for every occurrence of #include <malloc.h>?

All 12 comments

There is one in the tree at ./sys/oneway-malloc/include/malloc.h

The "real" posix malloc is defined in #include <stdlib.h>

@josephnoir is this fixed now? Can we close this issue?

No, this is not fixed.

Did you test @gebart's proposal? Are you willing to fix it :-)?

Is there a reason to use malloc.h over stdlib.h. It's my understanding that stdlib.h is more portable so it should be fine to change all #include <malloc.h> to #include <stdlib.h> or will this cause issues somewhere?

Unconditionally including stdlib.h leads to conflicts with native on Linux:

/home/lo/RIOT/sys/posix/pthread/include/pthread_threading_attr.h:34:3: error: conflicting types for ‘pthread_attr_t’

@LudwigOrtmann is that an error in either implementation or are we just not compatible with Linux?

I was able to use an if define to get around the malloc.h issue in OSX but I still couldn't compile because of #2360

@jhollister care to open a PR with your fix?

I don't have much experience with compatibility stuff like this. Is it correct to do something like:

#if defined(__MACH__)
#include <stdlib.h>
#else 
#include <malloc.h>

and should I do this for every occurrence of #include <malloc.h>?

You could also try to mess around with conditionally adding a local malloc.h for OSX (probably by extending the include path).

2590 has been merged

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jia200x picture jia200x  Â·  5Comments

kaspar030 picture kaspar030  Â·  6Comments

jcarrano picture jcarrano  Â·  5Comments

romainvause picture romainvause  Â·  3Comments

jue89 picture jue89  Â·  5Comments