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.

CODECOMPOSER: C2000 Cpp device support

Part Number: CODECOMPOSER
Other Parts Discussed in Thread: C2000WARE

Device: F29379D
CCS: Version: 10.2.0.00009
Compiler: TI v21.6.0 LTS

All,

Can someone point me to some documentation on how to use the provided C2000 device support with Cpp?

The current ones on C2000ware give me pragma and pointer casting errors.

Searches via Google and these forums about similar issues lead to dated threads with dead links.

Any information is appreciated!  Thanks.

  • Hi William,

    Please let me know if this is a correct understanding of the situation - you have a project with your own .cpp source files that are including the .h files for the above mentioned device from C2000Ware and you are running into compiler errors.

    Please could you post the specific error messages. 

    Thanks,
    Ashwini

  • 80/20 Rule! I figured it out. My project is a hybrid of a C and C++ that I am converting over.

    The "--cpp_default" parameter seems to break the the C2000Ware stuff.

    And the linker errors were an artifact of both C and C++ files including the headers with extern function prototypes.  There was basically a race condition on whether the function name was mangled (Cpp) or not (C) by the compiler.

    In general, I fixed this by removing the extern function prototypes from the H-files and putting then at the top of the cpp files that needed them.  It's a mess, but a temporary fix until the conversion is over.

    Is there any documentation on this? Or specifically converting to C++?

  • Hi William,

    Thanks for the follow up. I will check with the team and let you know.

    Thanks,
    Ashwini

  • There was basically a race condition on whether the function name was mangled (Cpp) or not (C) by the compiler.

    With CCS 10.4 imported the example C2000Ware (3.04.00.00) -> English -> Devices -> F2837XD -> F28379D -> Examples -> Driverlib -> CPU1 -> led_ex1_blinky

    After initially renaming the example source file led_ex1_blinky.c (C) to led_ex1_blinky.cpp (C++) got linker errors, which will be due to name mangling:

    Building target: "led_ex1_blinky.out"
    Invoking: C2000 Linker
    "/home/mr_halfword/ti/ccs1040/ccs/tools/compiler/ti-cgt-c2000_20.2.5.LTS/bin/cl2000" -v28 -ml -mt --cla_support=cla1 --float_support=fpu32 --tmu_support=tmu0 --vcu_support=vcu2 -Ooff --define=CPU1 --diag_suppress=10063 --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi -z -m"led_ex1_blinky.map" --stack_size=0x100 --warn_sections -i"/home/mr_halfword/ti/ccs1040/ccs/tools/compiler/ti-cgt-c2000_20.2.5.LTS/lib" -i"/home/mr_halfword/ti/ccs1040/ccs/tools/compiler/ti-cgt-c2000_20.2.5.LTS/include" --reread_libs --diag_wrap=off --display_error_number --xml_link_info="led_ex1_blinky_linkInfo.xml" --entry_point=code_start --rom_model -o "led_ex1_blinky.out" "./led_ex1_blinky.obj" "./device/F2837xD_CodeStartBranch.obj" "./device/device.obj" "../2837xD_RAM_lnk_cpu1.cmd" "/home/mr_halfword/ti/C2000Ware_3_04_00_00_Software/driverlib/f2837xd/driverlib/ccs/Debug/driverlib.lib"  -llibc.a 
    <Linking>
     
     undefined         first referenced    
      symbol               in file         
     ---------         ----------------    
     Device_init()     ./led_ex1_blinky.obj
     Device_initGPIO() ./led_ex1_blinky.obj
     
    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "led_ex1_blinky.out" not built
    In the led_ex1_blinky.cpp wrapped the C2000Ware includes in an extern "C" block:

    //
    // Included Files
    //
    extern "C" {
    #include "driverlib.h"
    #include "device.h"
    }
    

    With that change the example then successfully linked.

    In general, I fixed this by removing the extern function prototypes from the H-files and putting then at the top of the cpp files that needed them.  It's a mess, but a temporary fix until the conversion is over.

    Wrapping any C2000Ware includes in an extern "C" block within C++ source files may be a simpler work-around.

    Not sure if there is any plan to make the C2000Ware include files use #ifdef __cplusplus extern "C" to simplify calling C2000Ware functions from C++. See Add #ifdef __cplusplus extern "C" to all .h to enable calling from C++ for from some background information from a different project.

  • Chester,

    Thank you for your usual high quality response.

    Even with the extern "C" wrapper (I should have clarified that I did do this), I got the linker errors.  I enabled an option in the linker settings to not de-mangle the function calls in the console error dump, so that way I could see if it was a C (normal) or Cpp (mangled) reference to the function that was broken.

    I was in a bit of debugging frantic mode so I might be wrong here, but I think the issue was this:

    I had a Cpp file calling a function from another Cpp file, but the extern definition was in an H file that was included in a bunch of files, some C and some Cpp. Removing it from that file so that it was only listed in Cpp files fixed it.  Like I said, it was a mess.

  • Hi

    Chester and William,

    Thanks for the detailed responses above. The team reported that C2000Ware is not tested for C++. I will take notify the C2000Ware team of these observations.

    William,

    Are you unblocked at this time or are you still facing issues?

    Thanks,
    Ashwini

  • Yes, it currently works.