struct char c; // offset 0 int i; // offset 4 (padded 3 bytes after c) short s; // offset 8 // total size often 12 (pad to multiple of 4) sizeof(struct) may be larger than the sum of member sizes. 6. The setjmp / longjmp Non-Local Jump Analogous to goto across functions, but dangerous:
jmp_buf buf; if (setjmp(buf) == 0) // initial call deep_function(); else // returned from longjmp expert c programming deep c secrets
| Context | Behavior | |---------|----------| | extern char *s; | s is a pointer variable (holds address of a char). | | extern char t[]; | t is an array (address known at link time, no storage for address). | | char a[10]; | a is the address of the first element (array name is an address constant , not an lvalue). | | char *p = a; | Allowed: array decays to pointer. | | sizeof(a) | Returns 10 (size of array). | | sizeof(p) | Returns sizeof(char*) (e.g., 4 or 8). | struct char c; // offset 0 int i;
For modern C developers, these lessons remain critical—C is still the system programming lingua franca for kernels, embedded systems, and high-performance libraries. Van der Linden’s book is not a reference, but a guide to the traps —and knowing the traps is the mark of an expert. | | extern char t[]; | t is