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.

Compilation error "#159 expression must be an integral constant expression"

Other Parts Discussed in Thread: MSP430F2410

I am porting IAR Embedded workbench project source code to Code composer studio.5.5.0
The source code is building fine with IAR Embedded workbench IDE.
MCU is msp430f2410.

I am getting below Build errors and warning during compilation on the same line.

===================

Errors:

#159 expression must be an integral constant expression                 params.c    line 51

#66 expected a ";"                                                                                          params.c    line 51 

Warnings:

#78-D this declaration has no storage class or type specifier            params.c     line 51

===================

I need to know how do i make this IAR working code compatible with CCS.

Please suggest me some solution.

  • Adding source code in params.c from line 49 to line 51

    =======================================

    #pragma segment="BSLSKEY"
    #define BSLSKEY   _Pragma("location=\"BSLSKEY\"")
    BSLSKEY __root const WORD bslkey = 0xAA55;

    =======================================

  • To give more information , In IAR

    Extended keyword "__root" ensures bslkey is initialized even though unused by code.

    Need to write a compatible code for the above in CCS..

    Thanks in advance

  • I encourage you to read the section titled Pragma Directives in the MSP430 compiler manual.  

    In this particular case I think you need ...

    #pragma RETAIN(bslkey)
    #pragma DATA_SECTION(bslkey, "BSKSKEY")
    const WORD bslkey = 0xAA55;
    

    In your linker command file you can place the section BSKSKEY as needed.  An alternative to pragma DATA_SECTION is pragma LOCATION.  But LOCATION requires you know the address at compile time.

    Thanks and regards,

    -George

  • Thanks for the comment..

    >In your linker command file you can place the section BSKSKEY as needed.

    How i can do this in linker file? Can you provide me a example?

  • When you start a new project in CCS a linker command file is provided for you.  You are probably using lnk_msp430f2410.cmd.  An introduction to linker command files like that is in this wiki article.

    Thanks and regards,

    -George