Re: Help with structs



On Aug 27, 10:26 pm, Keith Thompson <ks...@xxxxxxx> wrote:
Gene <gene.ress...@xxxxxxxxx> writes:

[...]> Macros just do text replacement.  The main safety measure is to put
all parameters and the entire result in parens so you don't get
unexpected associativity problems.

[...]

My usual HHGTTG-inspired horrible example is:

#include <stdio.h>

#define SIX 1+5
#define NINE 8+1

int main(void)
{
    printf("%d * %d = %d\n", SIX, NINE, SIX * NINE);
    return 0;

}

Which would become 1+5*8+1 and return 42?

I'm assuming that in addition to order of operations issues there is
also a problem with variable capture as is the case with LISP style
macros? I know this is probably a stupid question but are there any
third-party hygenic macro packages available for C?

Thanks
Jack Trades
.



Relevant Pages