If you post C code to comp.lang.c, EVEN JOKE CODE, you're gonna
get people like me who ignore the [OT] tags and plunge ahead... ;-)
#define YEARDAYS ((ano % 4 == 0) && ano % 100 != 0) || ano % 400 == 0) ?\
^ Missing '('
Also, where is 'ano' defined? Much better practice would be to
take the value of 'ano' as an argument to a function-like macro,
YEARDAYS(foo).
Finally, you're missing a set of parentheses around the text of
the macro. Try compiling your original snippet; if sizeof(day) is
anything other than 1, you'll have a buffer overrun waiting to
happen. Operator precedence, man!
year * newYear {
static year *actual;
Style point: Missing explicit initialization of 'actual'. Adding
the '= NULL' couldn't hurt.
if(actual != NULL) free(actual);
return actual = (year) malloc(sizeof(day) * YEARDAYS);
Casting 'malloc' is BAD, because it can hide ERRORS like the pair
you have here. First, of course, you need to #include <stdlib.h>
for both 'free' and 'malloc' to work; and secondly, you're trying to
cast (void *) to (year), which may or may not work, depending on the
actual type of 'year'. You meant (year *) -- but you could have
written absolutely no cast at all, and been perfectly correct and
more readable to boot!
It's always New Year's somewhere on the Internet, I guess...
-Arthur