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.

CCS/MSP430FR2355: msp430fr2355.h has a #define ID line, which makes the TCAN4550 driver fail to build

Part Number: MSP430FR2355
Other Parts Discussed in Thread: TCAN4550

Tool/software: Code Composer Studio

I'm not sure if this is a bug with the MSP430 header or with TCAN4550, but I'd say that using a preprocessor definition for something as commonplace as "ID", is bad practice. See line 4968 of the official msp430fr2355.h - other devices might be affected too.

This causes code like

typedef struct {
 uint32_t ID : 29; //...

to fail, as ID for the compiler is now a 0x00c0 constant...

  • Hi,

    I'm not clear about your issue or question. Could you share me details about your issue? Maybe an example code and some compiling error message should be helpful. 

  • The ID in msp430fr2355.h has about 20 years of Prior Art, so I suspect it's unlikely to change, whatever the result of a philosophical debate in 2019.

    I suggest

    > #undef ID  // Avoid msp430.h conflict

  • Wei,

    this is the compiler error:

    >> Compilation failure
    subdir_rules.mk:7: recipe for target 'uart.obj' failed
    Building file: "../tcan4x5x/TCAN4550.c"
    Invoking: MSP430 Compiler
    "/home/zoe/ti/ccs920/ccs/tools/compiler/ti-cgt-msp430_19.6.0.STS/bin/cl430" -vmspx --data_model=large -Ooff --opt_for_speed=5 --use_hw_mpy=F5 --include_path="/home/zoe/ti/ccs920/ccs/ccs_base/msp430/include" --include_path="/home/zoe/ti/ccs920/ccs/ccs_base/msp430/include" --include_path="/home/zoe/projects/akupakk/software/firmware" --include_path="/home/zoe/ti/ccs920/ccs/tools/compiler/ti-cgt-msp430_19.6.0.STS/include" --include_path="/home/zoe/projects/akupakk/software/firmware/driverlib/MSP430FR2xx_4xx" --advice:power="all" --advice:hw_config="all" --define=DEBUG_ON --define=__MSP430FR2355__ -g --c11 --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 --preproc_with_compile --preproc_dependency="tcan4x5x/TCAN4550.d_raw" --obj_directory="tcan4x5x"  "../tcan4x5x/TCAN4550.c"
    (...)
    gmake: *** [uart.obj] Error 1
    "../tcan4x5x/TCAN4x5x_Data_Structs.h", line 524: error #41: expected an identifier
    "../tcan4x5x/TCAN4x5x_Data_Structs.h", line 565: error #41: expected an identifier
    "../tcan4x5x/TCAN4550.c", line 897: error #135: expected a field name
    "../tcan4x5x/TCAN4550.c", line 899: error #135: expected a field name

    The code in question is: (line 521 of the official TCAN4x5x_Data_Structs.h)

    typedef struct
    {
        //! @brief CAN ID received
        uint32_t ID : 29;

        //! @brief Remote Transmission Request flag
        uint8_t RTR : 1;

    The problem originates from the official msp430fr2355.h; if a file includes both the TCAN data structs header, and the msp430fr2355 header, the preprocessor replaces the word ID with the constant 0x00c0, which causes an error: the compiler wants an identifier in the struct, but sees a constant.

    So it's not possible to use the official TI TCAN4550 library with the official unmodified MSP430 library, without #undef-ing ID between them.

  • "it's 20 years of bad practice, so why change it?!"

    OK, boomer

**Attention** This is a public forum