2
In my first semester of college I did an algorithm in order to avoid memory waste, just for testing.
Now I’m passing this code to C:
Here’s the whole code:
// 8 bits
// Aguenta até 4 slots (0 - 3)
// Valor inteiro máximo suportado: 255
void setBit8(int *pInt32, int index, int valor)
{
*pInt32 = (*pInt32 & ~(0xff << index * 8)) ^ (valor << (index * 8));
}
int getBit8(int *pInt32, int index)
{
return ((*pInt32 >> (index * 8)) & (0xff >> 32));
}
// exemplo de uso:
setBit8(&var, 2, 168);
printf("%d", getBit8(&var, 2)); // imprime 168;
And I get the following warning in function getBit8
:
warning: right shift count >= width of type
The intention is to make the same variable of 4 bytes can receive up to 4 integer values within it, being able to access or modify these values, as a array...
What is the problem/error?
It would be able to provide the code that makes the method call?
– Mathiasfc
I’ll edit my question!
– MGM