From 0ee8e25677e536800e9b60ec9c94b2c462fd5023 Mon Sep 17 00:00:00 2001 From: Eric Chan Date: Wed, 10 Jul 2024 17:55:36 +0000 Subject: [PATCH] [external][ARM][CMSIS] prevent compilation error with C++ C++ have different behavior for const qualifier. The const qualifier used on a declaration of a non-local non-volatile non-template(since C++14)non-inline(since C++17) variable that is not declared extern gives it internal linkage. This is different from C where const file scope variables have external linkage. So add __BEGIN_CDECLS/__END_CDECLS to prevent compilation error. Original compilation error as below: arm-m/CMSIS/Include/cmsis_gcc.h:149:31: error: variable '__copy_table_start__' is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage 149 | extern const __copy_table_t __copy_table_start__; | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:154:40: note: used here 154 | for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:150:31: error: variable '__copy_table_end__' is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage 150 | extern const __copy_table_t __copy_table_end__; | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:154:72: note: used here 154 | for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:151:31: error: variable '__zero_table_start__ ' is used but not defined in this translation unit, and cannot be defined in any other translation uni t because its type does not have linkage 151 | exterlinking build-gdmc/gsp/platform/gsp/debugger.mod.on const __zero_table_t __zero_table_start__; | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:160:40: note: used here 160 | for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:151:31: error: variable '__zero_table_start__ ' is used but not defined in this translation unit, and cannot be defined in any other translation uni t because its type does not have linkage 151 | exterlinking build-gdmc/gsp/platform/gsp/debugger.mod.on const __zero_table_t __zero_table_start__; | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:160:40: note: used here 160 | for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:152:31: error: variable '__zero_table_end__' is used but not defined in this translation unit, and cannot be defined in any other translation unit because its type does not have linkage 152 | extern const __zero_table_t __zero_table_end__; | ^ lk/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h:160:72: note: used here 160 | for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { | --- external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h b/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h index dc3ae357f..7fb51ac59 100644 --- a/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h +++ b/external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h @@ -27,6 +27,7 @@ /* LK: include lk's compiler.h first, which has some of the same #defines */ #include +__BEGIN_CDECLS /* ignore some GCC warnings */ #pragma GCC diagnostic push @@ -2211,4 +2212,5 @@ __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) #pragma GCC diagnostic pop +__END_CDECLS #endif /* __CMSIS_GCC_H */