06-05-2016, 03:29 PM
Hi,
i am not sure about compliance of following example.
While exception to the rule 11.3 clearly says, that converting the pointer to object to pointer to char is ok and can be used for accessing individual bytes, Rule 18.1 says that object that is not an array shall be treated as an array of single element and does not allow dereferencing a pointer beyond the end of it.
Can an object that is not an array be treated as an array of 8-bit variables with length of its byte size for this purpose? or can i only access the first byte of the object this way?
thanks,
Michal
i am not sure about compliance of following example.
Code:
uint32_t varialble = 0;
uint8_t * ptr = (uint8_t *)variable;
(*ptr) = 0;
ptr++; //line in question
(*ptr) = 0; //line in question
While exception to the rule 11.3 clearly says, that converting the pointer to object to pointer to char is ok and can be used for accessing individual bytes, Rule 18.1 says that object that is not an array shall be treated as an array of single element and does not allow dereferencing a pointer beyond the end of it.
Can an object that is not an array be treated as an array of 8-bit variables with length of its byte size for this purpose? or can i only access the first byte of the object this way?
thanks,
Michal
<t></t>