How would you remove the warning produced by gcc -Wconversion
on the following code, without an explicit (=ugly) cast:
int main()
{
int val;
unsigned char c1 = (val % 65536) / 256;
unsigned char c2 = (val % 65536) % 256;
}
Is there a way to tell the compiler that obviously the cast is implicitely done during (% 65536) / 256
or % 256
For reference
$ gcc -Wconversion w.c
w.c: In function ‘main’:
w.c:4:36: warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]
w.c:5:36: warning: conversion to ‘unsigned char’ from ‘int’ may alter its value [-Wconversion]