Question
unsigned_int and unsigned_short_int compatibility ?
Posted on October 30, 2012 at 13:32
Hi there,
May be this is a silly question, but could someone explain me to how we use unsigned int and unsigned short int types together ? Here is an exemple from a simple working code (gpio.c* of STM32 VL Discovery MCU). In this code, I put in comments the questions running through my head.
volatile
unsigned
int
a;
unsigned
short
int
b;
unsigned
int
c;
unsigned
char
function_0()
if
( (a&b) != c)
// how is it possible to use a logic operation on two different types and then compare the result with an other type ?
...
else
....
}
unsigned
short
int
function_1(...)
{
....
return
( (unsigned
short
int
) a) ;
// As we convert one to the other, I understand from this line that the two types aren't compatible . right ?
}
void
function_2(...)
{
....
a = a | b;
// same question as for function_0().
a &= (~b);
}
(*) : I replaced the original variables : GPIO_x->IDR, GPIO_Pin and (unsigned int) )BIT_RESET with respectively: a, b, and c to make the code easier to read.
I wish this was clear and I'd much appreciate your help.
Thanks.
#'c'-textbook-question #unsigned #short #int