diff --git a/libraries/AP_InternalError/AP_InternalError.cpp b/libraries/AP_InternalError/AP_InternalError.cpp index 2bb3b3170e..bc505804a8 100644 --- a/libraries/AP_InternalError/AP_InternalError.cpp +++ b/libraries/AP_InternalError/AP_InternalError.cpp @@ -1,6 +1,12 @@ +#include "AP_InternalError_config.h" + +#if AP_INTERNALERROR_ENABLED + #include "AP_InternalError.h" -#include +#include +#include + #include extern const AP_HAL::HAL &hal; @@ -137,3 +143,5 @@ void AP_memory_guard_error(uint32_t size) AP_HAL::panic("memory guard size=%u\n", unsigned(size)); } } + +#endif // AP_INTERNALERROR_ENABLED diff --git a/libraries/AP_InternalError/AP_InternalError.h b/libraries/AP_InternalError/AP_InternalError.h index 4cbbb29043..d6936d978c 100644 --- a/libraries/AP_InternalError/AP_InternalError.h +++ b/libraries/AP_InternalError/AP_InternalError.h @@ -22,6 +22,10 @@ #pragma once +#include "AP_InternalError_config.h" + +#if AP_INTERNALERROR_ENABLED + #include class AP_InternalError { @@ -113,3 +117,7 @@ extern "C" { #define INTERNAL_ERROR(error_number) \ AP::internalerror().error(error_number, __AP_LINE__); + +#else // AP_INTERNALERROR_ENABLED is false +#define INTERNAL_ERROR(error_number) +#endif // AP_INTERNALERROR_ENABLED diff --git a/libraries/AP_InternalError/AP_InternalError_config.h b/libraries/AP_InternalError/AP_InternalError_config.h new file mode 100644 index 0000000000..64bbb03f69 --- /dev/null +++ b/libraries/AP_InternalError/AP_InternalError_config.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +#ifndef AP_INTERNALERROR_ENABLED +#define AP_INTERNALERROR_ENABLED 1 +#endif