STINNER Victor <vstin...@python.org> added the comment:
For me, one of the my worst issue is when a macro evalutes an argument twice. Example: --- #include <stdio.h> #define DOUBLE(value) ((value) + (value)) int main() { int x = 1; // expanded to: ((++x) + (++x)) int y = DOUBLE(++x); printf("x=%i y=%i\n", x, y); return 0; } --- Surprising output: --- $ gcc x.c -o x; ./x x=3 y=6 --- Expected output: --- x=2 y=4 --- Fixed code using a static inline function: --- #include <stdio.h> static inline int DOUBLE(int value) { return value + value; } int main() { int x = 1; // expanded to: DOUBLE(++x) int y = DOUBLE(++x); printf("x=%i y=%i\n", x, y); return 0; } --- Output: --- $ gcc x.c -o x; ./x x=2 y=4 --- ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43502> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com