AnsweredAssumed Answered

unsigned_int and unsigned_short_int compatibility ?

Question asked by kurlik.ed on Oct 30, 2012
Latest reply on Oct 30, 2012 by kurlik.ed
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.



01.volatile unsigned int  a;
02.unsigned short int b;
03.unsigned int c;
04.  
05.unsigned char  function_0()
06.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 ?
07....
08.else
09.....
10.}
11.  
12.unsigned short int function_1(...)
13.{
14.....
15.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 ?
16.}
17.  
18.  
19.void function_2(...)
20.{
21.....
22.a = a | b;  //  same question as for function_0().
23.a &= (~b);
24.}


(*) : 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.

Outcomes