RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

unknown type name: 'clockid_t' on OS X

Open josephnoir opened this issue 11 years ago • 5 comments

Using pthread on OS X results in this error message:

In file included from /Users/noir/Desktop/RIOT/tests/pthread/main.c:24:
In file included from /Users/noir/Desktop/RIOT/sys/posix/pthread/include/pthread.h:41:
/Users/noir/Desktop/RIOT/sys/posix/pthread/include/pthread_cond.h:87:63: error: unknown type name 'clockid_t'; did you mean 'clock_t'?
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/noir/Desktop/RIOT/cpu/native/periph
int pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id);
                                                              ^~~~~~~~~
                                                              clock_t
/usr/include/sys/_types/_clock_t.h:30:33: note: 'clock_t' declared here
typedef __darwin_clock_t        clock_t;
                                ^
In file included from /Users/noir/Desktop/RIOT/tests/pthread/main.c:24:
In file included from /Users/noir/Desktop/RIOT/sys/posix/pthread/include/pthread.h:41:
/Users/noir/Desktop/RIOT/sys/posix/pthread/include/pthread_cond.h:96:57: error: unknown type name 'clockid_t'; did you mean 'clock_t'?
int pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id);
                                                        ^~~~~~~~~
                                                        clock_t
/usr/include/sys/_types/_clock_t.h:30:33: note: 'clock_t' declared here
typedef __darwin_clock_t        clock_t;
                                ^
2 errors generated.
make[1]: *** [/Users/noir/Desktop/RIOT/tests/pthread/bin/native/pthread/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

josephnoir avatar Jan 27 '15 17:01 josephnoir

As the compiler output suggests, simply renaming all instances of clockid_t to clock_t fixes the problem on OS X. Not sure how this affects other platforms and compilers.

josephnoir avatar Mar 12 '15 15:03 josephnoir

From what I can find clock_t is defined as a long and clockid_t is an int. I think all we need to fix this compiler error is to conditionally create a typedef to an int for clockid_t in pthread_cond.h.

jhollister avatar Mar 21 '15 09:03 jhollister

That should work too. So the fix would be to add something like the following to the file:

#if defined(__APPLE__)
typedef int clockid_t;
#endif

josephnoir avatar Mar 24 '15 09:03 josephnoir

@jhollister, could you test #2811? Unfortunately I have no OSX machine to test it.

BytesGalore avatar Apr 14 '15 09:04 BytesGalore

Should be fixed with #2811.

josephnoir avatar Apr 21 '15 12:04 josephnoir