Is #define THING -10 completely safe?

Doug Gwyn gwyn at smoke.brl.mil
Mon Jan 28 16:11:16 AEST 1991


In article <1991Jan27.233142.28302 at watdragon.waterloo.edu> ccplumb at rose.uwaterloo.ca (Colin Plumb) writes:
-As all loyal followers of the Obfuscated C code contest know,
-array[i] == *(array+i) == *(i+array) == i[array].  So
-#define X1 -10
-#define X2 (-10)
-[...]
-printf("%d, %d\n", X1[p], X2[p]);
-Will print "-35, 15".

No, that's a ludicrous misinterpretation of the situation.  The
compiler does NOT perform a textual "rewrite" of the [] expression
then reparse it.



More information about the Comp.lang.c mailing list