AP_InternalError: improve gating of use of AP_InternalError library

- gate calls into library directly on the define
 - INTERNAL_ERROR becomes empty if library not compiled in
This commit is contained in:
Peter Barker 2023-08-15 14:14:02 +10:00 committed by Peter Barker
parent bb6f0ae527
commit 94e61a263d
3 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,12 @@
#include "AP_InternalError_config.h"
#if AP_INTERNALERROR_ENABLED
#include "AP_InternalError.h"
#include <AP_BoardConfig/AP_BoardConfig.h>
#include <AP_HAL/HAL.h>
#include <AP_HAL/Util.h>
#include <stdio.h>
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

View File

@ -22,6 +22,10 @@
#pragma once
#include "AP_InternalError_config.h"
#if AP_INTERNALERROR_ENABLED
#include <stdint.h>
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

View File

@ -0,0 +1,7 @@
#pragma once
#include <AP_HAL/AP_HAL_Boards.h>
#ifndef AP_INTERNALERROR_ENABLED
#define AP_INTERNALERROR_ENABLED 1
#endif