Error when compiling with the samd21.h library with C++ language

hello, good morning everybody! i have some doubts about this, i'm using an ATMEL SAMD2 microcontroller, i'm new to this compiler and they let me handle this micro in keil uvision.

I tried to make a library handling C++ language but I get these errors and this is the code:

I hope you can see the screenshots I captured, otherwise I leave the errors that marked me the compiler:

Build started: Project: Puerto 1
*** Using Compiler 'V6.14', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin'
Build target 'Target 1'
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(241): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/ac.h(226): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :2;               /*!< bit:  2.. 3  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/ac.h(228): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :3;               /*!< bit:  5.. 7  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/ac.h(232): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :2;               /*!< bit:  2.. 3  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/ac.h(234): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :3;               /*!< bit:  5.. 7  Reserved                           */
                 ^
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(242): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/adc.h(480): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :4;               /*!< bit:  4.. 7  Reserved                           */
                 ^
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(243): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/dac.h(181): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :5;               /*!< bit:  3.. 7  Reserved                           */
                 ^
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(244): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/dmac.h(826): error: anonymous bit-field cannot have qualifiers
    __I uint8_t  :5;               /*!< bit:  3.. 7  Reserved                           */
                 ^
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(246): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/eic.h(362): error: anonymous bit-field cannot have qualifiers
    __I uint32_t :16;              /*!< bit: 16..31  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/eic.h(366): error: anonymous bit-field cannot have qualifiers
    __I uint32_t :16;              /*!< bit: 16..31  Reserved                           */
                 ^
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(247): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/evsys.h(488): error: anonymous bit-field cannot have qualifiers
    __I uint32_t :4;               /*!< bit: 20..23  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/evsys.h(493): error: anonymous bit-field cannot have qualifiers
    __I uint32_t :4;               /*!< bit: 28..31  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/evsys.h(499): error: anonymous bit-field cannot have qualifiers
    __I uint32_t :4;               /*!< bit: 20..23  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/evsys.h(501): error: anonymous bit-field cannot have qualifiers
    __I uint32_t :4;               /*!< bit: 28..31  Reserved                           */
                 ^
prueba.cpp(3): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include\samd21.h(54): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/samd21g18a.h(250): warning: In file included from...
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/i2s.h(316): error: anonymous bit-field cannot have qualifiers
    __I uint16_t :2;               /*!< bit:  2.. 3  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/i2s.h(319): error: anonymous bit-field cannot have qualifiers
    __I uint16_t :2;               /*!< bit:  6.. 7  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/i2s.h(322): error: anonymous bit-field cannot have qualifiers
    __I uint16_t :2;               /*!< bit: 10..11  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/i2s.h(325): error: anonymous bit-field cannot have qualifiers
    __I uint16_t :2;               /*!< bit: 14..15  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/i2s.h(329): error: anonymous bit-field cannot have qualifiers
    __I uint16_t :2;               /*!< bit:  2.. 3  Reserved                           */
                 ^
C:/Users/uriel/AppData/Local/Arm/Packs/Keil/SAMD21_DFP/1.3.0/Device/SAMD21A/Include/component/i2s.h(331): error: anonymous bit-field cannot have qualifiers
    __I uint16_t :2;               /*!< bit:  6.. 7  Reserved                           */
                 ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
compiling prueba.cpp...
".\Objects\Puerto 1.axf" - 19 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01

I want to know if the microcontrollers of the ATMEL(Microchip) family support C++ language programming on keil uvision or do I have to use their ATMEL STUDIOS interface?

Parents
  • C++ is not a proper superset of C - there are a few things that are allowed in 'C', but not in C++.

    "anonymous bit-fields with qualifiers" would be one of them ...

    So 'C' code which relies upon such things cannot just be compiled as C++

    Similar issues exist with some of Nordic's SDK code.

Reply
  • C++ is not a proper superset of C - there are a few things that are allowed in 'C', but not in C++.

    "anonymous bit-fields with qualifiers" would be one of them ...

    So 'C' code which relies upon such things cannot just be compiled as C++

    Similar issues exist with some of Nordic's SDK code.

Children
No data
More questions in this forum