문제

I have compiler warning in code while setting 32nd bit. Code works but this warning annoys me.

Compiler is Keil C, processor is 32 bit ARM. Code is as following

PINSEL0 |= PINSEL_AD15;

where PINSEL0 is 32 bit register, defined as

#define PINSEL0         (*((volatile unsigned long *) 0xE002C000))

and PINSEL_AD15 is defined like:

#define PINSEL_AD15  ((1<<30)|(1<<31)) 

The warning message I'm receiving is: integer operation result is out of range

도움이 되었습니까?

해결책

The literal 1 is a signed integer, so when you shift by 31, you're going out of range. Try using an unsigned integer:

(1U << 31)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top