On my Compiler { Intel - Little Endian }, I have the size of Int and Long equal .
However, it is not universal and it may vary on different platforms .
#include <stdio.h>
#include <limits.h>
int main()
{
signed long int v1;
signed int v2;
printf("%d\n",sizeof(v1)); // 4
printf("%d\n",sizeof(v2)); // 4
printf("%u\n",UINT_MAX); // 4,294,967,295
printf("%lu\n",ULONG_MAX); // 4,294,967,295
if(-1L < 1U)
printf("I am Happy\n");
if(-1L < 1UL)
printf("I am Healthy");
return 0;
}
According to the integer promotional rules,
Int $\rightarrow$ Unsigned Int $\rightarrow$ Long $\rightarrow$ Unsigned Long
Both the IF blocks are identical for my compiler, as the size doesn't matter.
Hence, in the general, we are comparing Signed < Unsigned
Signed is promoted to unsigned and it will be a big number as size is $32$ bits. Comparing that less than $1$ is false, so both the blocks are never executed.
Hence, Nothing is printed .
EDIT :- When we use this compiler https://www.tutorialspoint.com/compile_c_online.php then output is I am Happy.
As in this compiler, size of int = $4$B and size of long = $8$B. Hence, in the first IF block, the comparison is like
if(-1L < 1L).
Now, this returns true and I am happy is printed.
NOTE :- If both of them(int and long) have equal size, then always promote both of them to the largest (Unsigned Long Int).