Kann man ein Makro definieren, das auf eine normale Variable zugreift, aber nur lesend (anders als bei einem Funktionsaufruf)? Kann zum Beispiel das VALUE-Makro im folgenden Code so definiert werden, dass die Funktion dostuff() einen Kompilierfehler verursacht?
struct myobj {
int value;
}
/* This macro does not satisfy the read-only requirement */
#define VALUE(o) (o)->value
/* This macro uses a function, unfortunately */
int getvalue(struct myobj *o) { return o->value; }
#define VALUE(o) getvalue(o)
void dostuff(struct myobj *foo) {
printf("The value of foo is %d.\n", VALUE(foo)); /* OK */
VALUE(foo) = 1; /* We want a compile error here */
foo->value = 1; /* This is ok. */
}