I have a situation where I pass an array containing 2 1 byte values to a function, but somehow the function thinks the array is 4 bytes long, which messes up my bit manipulation big-time. I even tried explicitly casting each array value as a uint8
,but to no avail. Any ideas about what might be happening? Using cygwin's gcc tools on Eclipse Mars.1.
typedef char uint8; //char is 1 byte in my system.
void setBitArray(uint8 bitArray[], int first, int last, uint8 type) {
if(first >= 0 && last < sizeof(bitArray) * 8) { // If the block is in bounds
...
}
}
...
int main() {
uint8 bitArray[2] = {(uint8)0, (uint8)0};
setBitArray(bitArray, 0,10, 1);
return 0;
}
EDIT
One more thing. sizeof(bitArray) yields 2 bytes in main().