Hi!
I'm getting some weird results from a (probably) valid C expression
with some #define... I'm really puzzled.
A sample code is this (just the variables and defines, not actual code):
#define themacro(p, i) (p)[(i)]
int *ptr, *anotherptr, counter;
themacro(ptr, counter)=anothe rptr=MEMORY_ALL OCATION(...);
Where memory_allocati on is a function which mallocs and reallocs
memory. I get a weird null pointer somewhere, and just writing:
anotherptr=MEMO RY_ALLOCATION(. ..);
themacro(ptr, counter)=anothe rptr;
solves the problem. Am I doing something out of standard?
--
Sensei <senseiwa@mac.c om>
Part of the inhumanity of the computer is that, once it is competently
programmed and working smoothly, it is completely honest. (Isaac Asimov)
I'm getting some weird results from a (probably) valid C expression
with some #define... I'm really puzzled.
A sample code is this (just the variables and defines, not actual code):
#define themacro(p, i) (p)[(i)]
int *ptr, *anotherptr, counter;
themacro(ptr, counter)=anothe rptr=MEMORY_ALL OCATION(...);
Where memory_allocati on is a function which mallocs and reallocs
memory. I get a weird null pointer somewhere, and just writing:
anotherptr=MEMO RY_ALLOCATION(. ..);
themacro(ptr, counter)=anothe rptr;
solves the problem. Am I doing something out of standard?
--
Sensei <senseiwa@mac.c om>
Part of the inhumanity of the computer is that, once it is competently
programmed and working smoothly, it is completely honest. (Isaac Asimov)
Comment