diff --git a/hal/src/main/native/athena/LEDs.cpp b/hal/src/main/native/athena/LEDs.cpp index 1009208fa26..f276db2be96 100644 --- a/hal/src/main/native/athena/LEDs.cpp +++ b/hal/src/main/native/athena/LEDs.cpp @@ -28,6 +28,7 @@ static const fs::path radioLEDRedFilePath = static const char* onStr = "1"; static const char* offStr = "0"; +extern "C" { void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) { std::error_code ec; fs::file_t greenFile = fs::OpenFileForWrite(radioLEDGreenFilePath, ec, @@ -49,3 +50,5 @@ void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) { fs::CloseFile(greenFile); fs::CloseFile(redFile); } + +} // extern "C" diff --git a/hal/src/main/native/cpp/jni/LEDJNI.cpp b/hal/src/main/native/cpp/jni/LEDJNI.cpp index e204c06c360..db3f842bf15 100644 --- a/hal/src/main/native/cpp/jni/LEDJNI.cpp +++ b/hal/src/main/native/cpp/jni/LEDJNI.cpp @@ -18,6 +18,8 @@ static_assert(edu_wpi_first_hal_LEDJNI_RADIO_LED_STATE_ORANGE == HAL_RadioLEDState::HAL_RadioLED_kOrange); using namespace hal; + +extern "C" { /* * Class: edu_wpi_first_hal_LEDJNI * Method: setRadioLEDState @@ -31,3 +33,4 @@ Java_edu_wpi_first_hal_LEDJNI_setRadioLEDState HAL_SetRadioLEDState(static_cast(state), &status); CheckStatus(env, status); } +} // extern "C" diff --git a/hal/src/main/native/include/hal/LEDs.h b/hal/src/main/native/include/hal/LEDs.h index 19e4122748d..3737b7df158 100644 --- a/hal/src/main/native/include/hal/LEDs.h +++ b/hal/src/main/native/include/hal/LEDs.h @@ -8,9 +8,16 @@ HAL_ENUM(HAL_RadioLEDState){HAL_RadioLED_kOff = 0, HAL_RadioLED_kGreen = 1, HAL_RadioLED_kRed = 2, HAL_RadioLED_kOrange = 3}; +#ifdef __cplusplus +extern "C" { +#endif /** * Set the state of the "Radio" LED. * @param state The state to set the LED to. * @param[out] status the error code, or 0 for success */ void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status); + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/hal/src/main/native/sim/LEDs.cpp b/hal/src/main/native/sim/LEDs.cpp index c31619839df..59f41edab69 100644 --- a/hal/src/main/native/sim/LEDs.cpp +++ b/hal/src/main/native/sim/LEDs.cpp @@ -10,6 +10,10 @@ namespace hal::init { void InitializeLEDs() {} } // namespace hal::init +extern "C" { + void HAL_SetRadioLEDState(HAL_RadioLEDState state, int32_t* status) { HALSIM_SetRoboRioRadioLEDState(state); } + +} // extern "C"