This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using CMSIS and stdlib.h at the same time

Other Parts Discussed in Thread: TM4C123GH6PM

Hello,

I have created project using "The CMSIS DSP Library in Code Composer Studio™ for TM4C MCUs" guide (www.ti.com/.../spma041f.pdf). The libraries had worked fine before I included <list> library, which, as i undestand, uses stdlib.h. Compiling the project with both libraries shows following error: 
"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/include/stdlib.h", line 150: error: expected a ";"
and warning:
"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/include/stdlib.h", line 150: warning: this declaration has no storage class or type specifier

Investigating the problem i have noticed that clearing Predefined Symbol "_LINKAGE" allows to use <list> as well as stdlib.h library, but not CMSIS library. One of the errors (others are the same), which occurs when _LINKAGE Predefinition symbol is cleared:
"D:/.../CMSIS/Include/arm_math.h", line 459: error: more than one storage class may not be specified

So the is question: Is it possible / How to use both libraries at the same time ? 

Thanks,

Nikolai

  • We who watch this forum are not familiar with the CMSIS library.  My guess is that it is not tested for use with C++.  You could try to debug the issue by using the compiler options --gen_acp_raw (helps with debugging preprocessor issues) and --verbose_diagnostics (often helps pinpoint where an error originates).  Read about those options in the ARM compiler manual.  If you are still stuck after that, I recommend you start a new thread in the TM4C device forum.  Or, if you prefer, I can move this thread into that forum.

    Thanks and regards,

    -George

  • I have tried to fix the problem by adding this two compiler options (--gen_acp_raw and --verbose diagnostics), but it didn't help me.

    If this problem doesn't fit to current forum, it would be great, if You could move it to correct one.

    Thanks,

    Nikolai
  • Do not define the symbol _LINKAGE. That identifier is used by the TI RTS header file linkage.h, used by a large number of header files in the RTS. If you define this symbol, you'll alter the behavior of the entire RTS.

    CMSIS has several include files. Which other ones are you including in your project? In what order are you including these header files?

    Note to myself: line 150 in stdlib.h for TMS470 5.2.2 is the declaration of atof. It happens to be the first declaration to use _IDECL.
  • I have been using only "arm_math.h" include file to operate with DSP library.
  • I've looked at that file briefly, and I don't know what's going on. They do seem to be making their own definition of the macro __INLINE, which interferes with the TI compiler RTS's definition (from linkage.h). My guess is that CMSIS and the RTS header files are not compatible at this time.
  • Archaeologist said:
    . They do seem to be making their own definition of the macro __INLINE, which interferes with the TI compiler RTS's definition (from linkage.h)

    Agreed.

    One work-around is to add predefined symbols for _LINKAGE, _CODE_ACCESS="" and _DATA_ACCESS="" to the CCS Project Properties - see https://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/390789/1382038#1382038

    Haven't determine a more satisfactory work-around.

  • I have added these symbols as well as TARGET_IS_TM4C123_RB1, __GNUC__, ARM_MATH_CM4, __FPU_PRESENT=1, and have made every recomended step from this source - http://www.ti.com/lit/an/spma041f/spma041f.pdf, but libraries still doesn't work correctly.

  • In what way does the library not work? What is the symptom? Is there a compiler or linker error message?
  • I have created executable test project to demonstrate the problem. The project has only main.c file, which contains following instructions:

    #include "arm_math.h"

    #include <list>

    int main(void) {

    return 0;
    }

    So if I leave "_LINKAGE" predefined symbol and build the project, the following console message would occur:

    **** Build of configuration Debug for project TestProject ****

    "C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building file: ../main.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 --opt_for_speed=0 --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include" --include_path="D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include" -g --cpp_default --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 --define=__GNUC__ --define=ARM_MATH_CM4 --define=__FPU_PRESENT=1 --define=_LINKAGE --define=_CODE_ACCESS="" --define=_DATA_ACCESS="" --diag_warning=225 --diag_wrap=off --ual --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include/stdlib.h", line 150: warning: this declaration has no storage class or type specifier
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include/stdlib.h", line 150: error: expected a ";"
    1 error detected in the compilation of "../main.c".

    >> Compilation failure
    gmake: *** [main.obj] Error 1
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****


    If I erased "_LINKAGE" predefined symbol, then following console message would occur:


    **** Build of configuration Debug for project TestProject ****

    "C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building file: ../main.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 --opt_for_speed=0 --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include" --include_path="D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include" -g --cpp_default --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 --define=__GNUC__ --define=ARM_MATH_CM4 --define=__FPU_PRESENT=1 --define=_CODE_ACCESS="" --define=_DATA_ACCESS="" --diag_warning=225 --diag_wrap=off --ual --preproc_with_compile --preproc_dependency="main.pp" "../main.c"
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include/linkage.h", line 56: warning: incompatible redefinition of macro "__INLINE" (declared at line 86 of "D:\dektop\repository\MK\ARM\ARM_CMSIS\CMSIS\Include\core_cm4.h")
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 459: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 469: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 479: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 489: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 500: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 541: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 592: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5088: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5123: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5171: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5290: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5320: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5395: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5424: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5511: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5545: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5630: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5665: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5763: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5822: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5884: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 5944: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6089: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6149: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6194: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6249: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6294: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6351: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 6396: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 7137: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 7205: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 7281: error: more than one storage class may not be specified
    "D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include/arm_math.h", line 7361: error: more than one storage class may not be specified
    33 errors detected in the compilation of "../main.c".

    >> Compilation failure
    gmake: *** [main.obj] Error 1
    'Building file: ../tm4c123gh6pm_startup_ccs.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -O2 --opt_for_speed=0 --include_path="C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include" --include_path="D:/dektop/repository/MK/ARM/ARM_CMSIS/CMSIS/Include" -g --gcc --define=ccs="ccs" --define=PART_TM4C123GH6PM --define=TARGET_IS_TM4C123_RB1 --define=__GNUC__ --define=ARM_MATH_CM4 --define=__FPU_PRESENT=1 --define=_CODE_ACCESS="" --define=_DATA_ACCESS="" --diag_warning=225 --diag_wrap=off --ual --preproc_with_compile --preproc_dependency="tm4c123gh6pm_startup_ccs.pp" "../tm4c123gh6pm_startup_ccs.c"
    'Finished building: ../tm4c123gh6pm_startup_ccs.c'
    ' '
    gmake: Target `all' not remade because of errors.

    **** Build Finished ****

    The test project:

    TestProject.rar

    So the question is: Is it possible to include both files at the same time ?

    Thanks

  • I think the answer is "no," that CMSIS and the RTS header files are not compatible at this time.

    Okay, those error messages make sense to me given what I've seen in the header files. I don't know what the resolution will be; we're going to have to look into it.
  • Thank You for efficiency!

    Nikolai
  • I am having the same/similar issue. I am not using list or any "C++ features".

    To workaround this, I just commented out the definition of for __INLINE in linkage.h. I can build without the warning but I don't know what the consequences are going to be.
  • Hello Nikolai,

    The Application Note is being updated to make the integration process for CMSIS DSP inclusion in CCS simpler and robust. It would be a couple of weeks before it shows up on the web. In the meantime I will post the changes from the existing version of the Application Note and the software package for you (and potentially other forum members to use)

    1. ARM Compiler 5.2.5

    2. Support Package Update

    CMSIS.zip

    3. Changes

    (a) Only arm_bitreversal2.asm, cmsis_ccs.h and arm_math.h need to be updated in the CMSIS 4.2 Package. Please revert the other 3 files to the CMSIS 4.2 Package

    (b) Remove the define for __GNUC__, _LINKAGE, _CODE_ACCESS="" and _DATA_ACCESS="" in Section-3 Step 10 and Section-4 Step 7

    Regards

    Amit