ros / roscpp_core

ros distribution sandbox
89 stars 116 forks source link

add logic to support steady time on macOS #59

Closed wjwwood closed 7 years ago

wjwwood commented 7 years ago

Without this fix I get this when compiling:

Scanning dependencies of target rostime
[ 25%] Building CXX object CMakeFiles/rostime.dir/src/duration.cpp.o
[ 50%] Building CXX object CMakeFiles/rostime.dir/src/rate.cpp.o
[ 75%] Building CXX object CMakeFiles/rostime.dir/src/time.cpp.o
/tmp/test_ct/src/roscpp_core/rostime/src/time.cpp:178:19: error: use of undeclared identifier 'CLOCK_MONOTONIC'
    clock_gettime(CLOCK_MONOTONIC, &start);
                  ^
1 error generated.
make[2]: *** [CMakeFiles/rostime.dir/src/time.cpp.o] Error 1
make[1]: *** [CMakeFiles/rostime.dir/all] Error 2
make: *** [all] Error 2

I think this is a regression from https://github.com/ros/roscpp_core/pull/57, but only for macOS (perhaps other BSD systems).

The SYSTEM_CLOCK when used with host_get_clock_service is the correct way to get a monotonic clock on macOS, despite "system clock" meaning something else in C++ and other lingo:

https://stackoverflow.com/a/11681069/671658