diff --git a/CMakeLists.txt b/CMakeLists.txt index c1bc1b494e..df4ebe309f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,12 @@ include(kconfig) message(STATUS "PX4 config: ${PX4_CONFIG}") message(STATUS "PX4 platform: ${PX4_PLATFORM}") +if($ENV{CLION_IDE}) + # CLion automatically executes some compiler commands after configuring the + # project. This would fail on NuttX, as visibility.h tries to (indirectly) + # include nuttx/config.h, which at that point does not exist yet + add_definitions(-DPX4_DISABLE_GCC_POISON) +endif() if(${PX4_PLATFORM} STREQUAL "posix") if(ENABLE_LOCKSTEP_SCHEDULER) diff --git a/src/include/visibility.h b/src/include/visibility.h index 5de2682a8c..b56ef0b4d9 100644 --- a/src/include/visibility.h +++ b/src/include/visibility.h @@ -60,14 +60,19 @@ #endif +#define system_exit exit +#define system_clock_gettime clock_gettime +#define system_clock_settime clock_settime +#define system_pthread_cond_timedwait pthread_cond_timedwait +#define system_usleep usleep +#define system_sleep sleep - +#ifndef PX4_DISABLE_GCC_POISON /* exit() is used on NuttX to exit a task. However on Posix, it will exit the * whole application, so we prevent its use there. There are cases where it * still needs to be used, thus we remap system_exit to exit. */ -#define system_exit exit #if !defined(__PX4_NUTTX) #include #ifdef __cplusplus @@ -83,8 +88,6 @@ /* For SITL lockstep we fake the clock, sleeping, and timedwaits * Therefore, we prefix these syscalls with system_. */ #include -#define system_clock_gettime clock_gettime -#define system_clock_settime clock_settime /* We can't poison clock_settime/clock_gettime because they are * used in DriverFramework. */ @@ -93,20 +96,17 @@ // We can't include this for NuttX otherwise we get conflicts for read/write // symbols in cannode. #endif // !defined(__PX4_NUTTX) -#define system_pthread_cond_timedwait pthread_cond_timedwait /* We can't poison pthread_cond_timedwait because it seems to be used in the * include. */ /* We don't poison usleep and sleep because it is used in dependencies - * like uavcan and DriverFramework. */ + * like uavcan. */ #if !defined(__PX4_NUTTX) #include // We can't include this for NuttX otherwise we get conflicts for read/write // symbols in cannode. #endif // !defined(__PX4_NUTTX) -#define system_usleep usleep -#define system_sleep sleep /* On NuttX we call clearenv() so we cannot use getenv() and others (see @@ -123,3 +123,5 @@ * need to get changed. */ #pragma GCC poison getenv setenv putenv #endif // defined(__PX4_NUTTX) + +#endif // PX4_DISABLE_GCC_POISON