large integer implicitly truncated to unsigned type

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

large integer implicitly truncated to unsigned type

3,317 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JulianCox on Fri Apr 22 10:19:31 MST 2016
I have the following declaration in my program: -
#define PORT_MASK       0x100E1011UL
but when I compile it I get the warning: -
../example/src/gpio.c:42:25: warning: large integer implicitly truncated to unsigned type [-Woverflow]
I thought that UL declared a variable as Long and unsigned. Why do I get this warning?
0 项奖励
4 回复数

1,667 次查看
lpcware
NXP Employee
NXP Employee
bump
0 项奖励

1,667 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by JulianCox on Mon Apr 25 09:07:25 MST 2016
Thanks for the help. Yes, I am using LPCOpen with the LPC824. I changed the declaration in the function parameter list and the warning has gone away.
0 项奖励

1,666 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DF9DQ on Fri Apr 22 10:27:39 MST 2016
Are you using this with LPCOpen for LPC800?

The error occurs when the constant is used as a parameter to Chip_GPIO_SetPortDIROutput() (some others have the same mistake). The "mask" parameter there is declared as uint8_t while it should in fact be uint32_t.
0 项奖励

1,667 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vtw.433e on Fri Apr 22 10:27:21 MST 2016
There is nothing's no wrong with your #define, and the compiler is not complaining about it. You will have to show us how you are using it (I.e. The line causing the error) for us to be able to help you.
0 项奖励