diff --git a/libraries/AP_HAL/board/chibios.h b/libraries/AP_HAL/board/chibios.h index 1e3549fa94..b06642742d 100644 --- a/libraries/AP_HAL/board/chibios.h +++ b/libraries/AP_HAL/board/chibios.h @@ -59,12 +59,14 @@ #define HAL_WITH_EKF_DOUBLE HAL_HAVE_HARDWARE_DOUBLE #endif +#ifdef __cplusplus // allow for static semaphores #include #define HAL_Semaphore ChibiOS::Semaphore #include #define HAL_EventHandle AP_HAL::EventHandle +#endif /* string names for well known SPI devices */ #define HAL_BARO_MS5611_NAME "ms5611" diff --git a/libraries/AP_HAL/board/esp32.h b/libraries/AP_HAL/board/esp32.h index 560920fc09..4c7bff3ef5 100644 --- a/libraries/AP_HAL/board/esp32.h +++ b/libraries/AP_HAL/board/esp32.h @@ -23,9 +23,11 @@ #define O_CLOEXEC 0 #define HAL_STORAGE_SIZE (16384) +#ifdef __cplusplus // allow for static semaphores #include #define HAL_Semaphore ESP32::Semaphore +#endif #define HAL_NUM_CAN_IFACES 0 #define HAL_MEM_CLASS HAL_MEM_CLASS_192 diff --git a/libraries/AP_HAL/board/linux.h b/libraries/AP_HAL/board/linux.h index 58e714b1f7..78eba130d9 100644 --- a/libraries/AP_HAL/board/linux.h +++ b/libraries/AP_HAL/board/linux.h @@ -380,10 +380,13 @@ #define HAL_LINUX_I2C_EXTERNAL_BUS_MASK 0xFFFF #endif +// only include if compiling C++ code +#ifdef __cplusplus #include #define HAL_Semaphore Linux::Semaphore #include #define HAL_EventHandle AP_HAL::EventHandle +#endif #ifndef HAL_HAVE_HARDWARE_DOUBLE #define HAL_HAVE_HARDWARE_DOUBLE 1 diff --git a/libraries/AP_HAL/board/sitl.h b/libraries/AP_HAL/board/sitl.h index 3d288adc25..f3f378d32a 100644 --- a/libraries/AP_HAL/board/sitl.h +++ b/libraries/AP_HAL/board/sitl.h @@ -50,12 +50,15 @@ #define HAL_HAVE_SERVO_VOLTAGE 1 #define HAL_HAVE_SAFETY_SWITCH 0 +// only include if compiling C++ code +#ifdef __cplusplus // allow for static semaphores #include #define HAL_Semaphore HALSITL::Semaphore #include #define HAL_EventHandle AP_HAL::EventHandle +#endif #ifndef HAL_NUM_CAN_IFACES #define HAL_NUM_CAN_IFACES 0