S
Sensei
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)=anotherptr=MEMORY_ALLOCATION(...);
Where memory_allocation is a function which mallocs and reallocs
memory. I get a weird null pointer somewhere, and just writing:
anotherptr=MEMORY_ALLOCATION(...);
themacro(ptr, counter)=anotherptr;
solves the problem. Am I doing something out of standard?
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)=anotherptr=MEMORY_ALLOCATION(...);
Where memory_allocation is a function which mallocs and reallocs
memory. I get a weird null pointer somewhere, and just writing:
anotherptr=MEMORY_ALLOCATION(...);
themacro(ptr, counter)=anotherptr;
solves the problem. Am I doing something out of standard?