large integer implicitly truncated to unsigned type

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

large integer implicitly truncated to unsigned type

3,351件の閲覧回数
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,701件の閲覧回数
lpcware
NXP Employee
NXP Employee
bump
0 件の賞賛

1,701件の閲覧回数
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,700件の閲覧回数
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,701件の閲覧回数
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 件の賞賛