[riot-notifications] [RIOT] Native: build of vtimer_msg test fails on OS X (#3175)

ximus notifications at github.com
Tue Jun 16 01:44:54 CEST 2015


This also happens when running the entire test suite `cd tests/unittests && make`
My output is slightly different (different location of task.h), but essentially the same error:

```
~/c/R/t/unittests (master) $ make
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Building application "unittests" for "native" with MCU "native".

touch /Users/me/code/RIOT/tests/unittests/main.c
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/boards/native
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/boards/native/drivers
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/core
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/cpu/native
In file included from /Users/me/code/RIOT/cpu/native/hwtimer_cpu.c:47:
In file included from /Users/me/code/RIOT/core/include/debug.h:34:
/Users/me/code/RIOT/core/include/thread.h:138:14: error: conflicting types for 'thread_create'
kernel_pid_t thread_create(char *stack,
             ^
/usr/include/mach/task.h:193:15: note: previous declaration is here
kern_return_t thread_create
              ^
1 error generated.
make[2]: *** [/Users/me/code/RIOT/tests/unittests/bin/native/cpu/hwtimer_cpu.o] Error 1
make[1]: *** [ALL--/Users/me/code/RIOT/cpu/native] Error 2
make: *** [all] Error 2
```

The issue is `cpu/native/hwtimer_cpu.c` on OSX includes `mach/mach.h` which includes `mach/mach_interface.h` which includes `mach/task.h` which defines `thread_create()` which conflicts with Riot's own `thread_create()`.

I see two solutions:
* Rename the conflicting method(s). Downside is `thread_create()` is a good and existing name.
* Rework the mach dependencies, which is possible. This works for the time being. I was able to get past the error with the following change:

```
diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c
index 2dc9f1b..4fe0e17 100644
--- a/cpu/native/hwtimer_cpu.c
+++ b/cpu/native/hwtimer_cpu.c
@@ -23,7 +23,8 @@

 #ifdef __MACH__
 #include <mach/clock.h>
-#include <mach/mach.h>
+#include <mach/mach_init.h>
+#include <mach/mach_port.h>
 #endif

 #include <time.h>
```

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/3175#issuecomment-112238886
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150615/4ad702b4/attachment.html>


More information about the notifications mailing list