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 v7.1中无法定义unsigned int型变量

Other Parts Discussed in Thread: MSP430F149

各位老师,请教以下问题:

我在CCS v7.1中建立一个msp430f149的项目,定义一个unsigned int类型的变量,让其从0开始累加,累加到32767时都是正常的,累加到32768时却变成了-32768,我明明定义的是unsigned int类型的变量,为啥会出现这个问题?请指教

  • Laiyuan Gao 说:

    各位老师,请教以下问题:

    我在CCS v7.1中建立一个msp430f149的项目,定义一个unsigned int类型的变量,让其从0开始累加,累加到32767时都是正常的,累加到32768时却变成了-32768,我明明定义的是unsigned int类型的变量,为啥会出现这个问题?请指教

    工程或者代码贴上来

  • 你好,请试一试在定义变量的时候这样写

    volatile unsigned int i;

    可以避免变量的数据类型因为优化而改变。