I would like to initialize the short value with a hexadecimal value, but my compiler gives me truncation warnings. It is clear that I am trying to set short to a positive value.
short my_value = 0xF00D;
How would you avoid this warning? I could use a negative value,
short my_value = -4083; // In 2 complement this is 0xF00D
but in my code it is much clearer to use hex.
c ++ initialization warnings truncation
M. Dudley
source share