I've been looking in a few header files at the methods other people are using for macros, in particular the stdarg.h file (Someone on the OS dev board mentioned it).
Anyway. The macro that's bugging me follows this format:
Code: Select all
#define a_macro(arg) (arg = (Some value), (void) 0)
Code: Select all
a_macro (arg);
Code: Select all
A = (( B = 20), 50);
Means:
A = 50;
B = 20;
Code: Select all
a_macro (arg);
Gets replaced with:
(arg = (Some value), (void) 0)
Which means:
arg1 = (Some value);
(void) 0;
Code: Select all
int i;
(i=2, (void) 0);
printf("%d", i);
So I guess the question here is just what the heck that (void) 0 is achieving? It seems to serve no purpose whatsoever. I took a good long look around the web this afternoon and couldn't find anything explaining it. I know it isn't an isolated thing because I went digging around a whole bunch of header files after finding this and it is used all over the place. I'm guessing it's just such a widely followed practice, or is so obvious, that nobody has bothered writing down WHY it's done.
Any chance one of the C gurus could please give an explanation?