Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

malloc.h not found on OS X #2361

Closed
josephnoir opened this issue Jan 27, 2015 · 12 comments
Closed

malloc.h not found on OS X #2361

josephnoir opened this issue Jan 27, 2015 · 12 comments
Assignees
Labels
OS: Mac OS X Host OS: This PR/issue concerns usage of RIOT with Mac OS X as a host system Platform: native Platform: This PR/issue effects the native platform

Comments

@josephnoir
Copy link
Contributor

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.
@josephnoir josephnoir added Platform: native Platform: This PR/issue effects the native platform OS: Mac OS X Host OS: This PR/issue concerns usage of RIOT with Mac OS X as a host system labels Jan 27, 2015
@jnohlgard
Copy link
Member

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

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

@PeterKietzmann
Copy link
Member

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

@josephnoir
Copy link
Contributor Author

No, this is not fixed.

@PeterKietzmann
Copy link
Member

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

@jhollister
Copy link
Contributor

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?

@LudwigKnuepfer
Copy link
Member

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’

@jnohlgard
Copy link
Member

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

@jhollister
Copy link
Contributor

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

@LudwigKnuepfer
Copy link
Member

@jhollister care to open a PR with your fix?

@jhollister
Copy link
Contributor

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

@LudwigKnuepfer
Copy link
Member

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

@LudwigKnuepfer
Copy link
Member

#2590 has been merged

@OlegHahm OlegHahm modified the milestone: Release 2015.09 Sep 7, 2015
jhandfield added a commit to jhandfield/Rom24b6-gcc4 that referenced this issue Jan 13, 2018
macOS doesn't seem to have a malloc.h readily available, but as per random
Google result at RIOT-OS/RIOT#2361 we can just include
<stdlib.h> in its place.
darren added a commit to darren/fftw that referenced this issue Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Mac OS X Host OS: This PR/issue concerns usage of RIOT with Mac OS X as a host system Platform: native Platform: This PR/issue effects the native platform
Projects
None yet
Development

No branches or pull requests

7 participants