Tutorial by Examples

If an object is defined with static, thread, or automatic storage duration, and it has a character type, either: char, unsigned char, or signed char, it may not be accessed by a non-character type. In the below example a char array is reinterpreted as the type int, and the behavior is undefined on e...
The effective type of a data object is the last type information that was associated with it, if any. // a normal variable, effective type uint32_t, and this type never changes uint32_t a = 0.0; // effective type of *pa is uint32_t, too, simply // because *pa is the object a uint32_t* pa = &a...
In the following code let us assume for simplicity that float and uint32_t have the same size. void fun(uint32_t* u, float* f) { float a = *f *u = 22; float b = *f; print("%g should equal %g\n", a, b); } u and f have different base type, and thus the compiler can a...
If we have two pointer arguments of the same type, the compiler can't make any assumption and will always have to assume that the change to *e may change *f: void fun(float* e, float* f) { float a = *f *e = 22; float b = *f; print("is %g equal to %g?\n", a, b); } f...
Once an object has an effective type, you should not attempt to modify it through a pointer of another type, unless that other type is a character type, char, signed char or unsigned char. #include <inttypes.h> #include <stdio.h> int main(void) { uint32_t a = 57; // conversion...

Page 1 of 1