Skip to content

Commit

Permalink
[external][ARM][CMSIS] prevent compilation error with C++
Browse files Browse the repository at this point in the history
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) {
      |
  • Loading branch information
ericchancf committed Aug 11, 2024
1 parent 28aa11e commit 0ee8e25
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions external/arch/arm/arm-m/CMSIS/Include/cmsis_gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

/* LK: include lk's compiler.h first, which has some of the same #defines */
#include <lk/compiler.h>
__BEGIN_CDECLS

/* ignore some GCC warnings */
#pragma GCC diagnostic push
Expand Down Expand Up @@ -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 */

0 comments on commit 0ee8e25

Please sign in to comment.