This commit is contained in:
Miloslav Ciz 2024-04-29 21:44:17 +02:00
parent b82dd9c6da
commit c863684c6d
10 changed files with 1856 additions and 1736 deletions

View file

@ -152,4 +152,6 @@ Watch out for **operator precedence**! C infamously has weird precedence with so
Watch out for **[macro](macro.md) arguments**, always bracket them because they get substituted on text level. Consider e.g. a macro `#define divide(a,b) a / b`, and then doing `divide(3 + 1,2)` -- this gets expanded to `3 + 1 / 2` while you probably wanted `(3 + 1) / 2`, i.e. the macro should have been defined as `#define divide(a,b) (a) / (b)`.
This may get some beginners: `for (unsigned char i = 0; i < 256; ++i) { ... }` -- this loop will never end because the data type is not big enough to surpass the iteration limit. Similarly this may happen if you use e.g. unsigned int and 65536 and so on. New compilers will warn you about this.
This is not really a pitfall, rather a headscratcher, but don't forget to link math library with `-lm` flag when using using the `math.h` library.