B
Ben
This is a follow-on from the "Help with array/pointer segmentation fault needed" thread..
I have not been able to find much information on the rules for macros. I want to be able to call a macro from outside it's
definition which I am fairly sure I have seen done before. This code works:
#define TEST(where,dimension,ptr) \
printf ("\tAll %s in %s values: ",where,dimension); \
pointer = mArray[bb][cc][rr][vv]; \
while (pointer!=NULL) { \
printf ("%c",pointer->symbol); \
pointer = pointer->ptr; \
} \
printf("\n");
TEST("prev","block ",prev_in_block);
TEST("prev","column",prev_in_column);
TEST("prev","row ",prev_in_row);
#undef TEST
But this does not:
#define TEST(where,dimension,ptr) \
printf ("\tAll %s in %s values: ",where,dimension); \
pointer = mArray[bb][cc][rr][vv]; \
while (pointer!=NULL) { \
printf ("%c",pointer->symbol); \
pointer = pointer->ptr; \
} \
printf("\n");
#undef TEST
TEST("prev","block ",prev_in_block);
TEST("prev","column",prev_in_column);
TEST("prev","row ",prev_in_row);
with errors:
[Warning] implicit declaration of function `TEST'
`prev_in_block' undeclared (first use in this function)
`prev_in_column' undeclared (first use in this function)
`prev_in_row' undeclared (first use in this function)
[Warning] unused variable `pointer'
The reason for this is I have several blocks of code where only the inner loop needs to be macroed, the preceeding lines of each
block are not suitable for macroing.
Can anyone point me to a good reference or just explain what I need to do call a macro from outside it's definition (if it's
possible)?
cheers,
Ben
I have not been able to find much information on the rules for macros. I want to be able to call a macro from outside it's
definition which I am fairly sure I have seen done before. This code works:
#define TEST(where,dimension,ptr) \
printf ("\tAll %s in %s values: ",where,dimension); \
pointer = mArray[bb][cc][rr][vv]; \
while (pointer!=NULL) { \
printf ("%c",pointer->symbol); \
pointer = pointer->ptr; \
} \
printf("\n");
TEST("prev","block ",prev_in_block);
TEST("prev","column",prev_in_column);
TEST("prev","row ",prev_in_row);
#undef TEST
But this does not:
#define TEST(where,dimension,ptr) \
printf ("\tAll %s in %s values: ",where,dimension); \
pointer = mArray[bb][cc][rr][vv]; \
while (pointer!=NULL) { \
printf ("%c",pointer->symbol); \
pointer = pointer->ptr; \
} \
printf("\n");
#undef TEST
TEST("prev","block ",prev_in_block);
TEST("prev","column",prev_in_column);
TEST("prev","row ",prev_in_row);
with errors:
[Warning] implicit declaration of function `TEST'
`prev_in_block' undeclared (first use in this function)
`prev_in_column' undeclared (first use in this function)
`prev_in_row' undeclared (first use in this function)
[Warning] unused variable `pointer'
The reason for this is I have several blocks of code where only the inner loop needs to be macroed, the preceeding lines of each
block are not suitable for macroing.
Can anyone point me to a good reference or just explain what I need to do call a macro from outside it's definition (if it's
possible)?
cheers,
Ben