This post is used to record one mistake while my coding – just for my bad memory:) I have to admit that it spent me the whole day to figure out what was wrong, as it looked prefect except parse error during compiling. At least 2 things are revealed: 1, I suck on C; 2, I need to learn compiler theory…
#include <stdio.h>
#include <stdlib.h>
typedef struct _Big{
char big;
int bigInt;
}Big;
typedef struct _Bigger{
char bigger;
Big *bigP;
}Bigger;
typedef struct _Biggest{
char biggest;
Bigger *biggerP;
}Biggest;
#define GET_BIG( _biggestP)
((_biggestP)->biggerP->bigP)
#define BIGINT_IS_ONE( _biggestP, _bigInt)
( 1 == GET_BIG( _biggestP)->(_bigInt))
// daveti: insane happens here, like 'xxx->(xxx)'
int main(void)
{
Biggest *bP = calloc( 1, sizeof( Biggest));
bP->biggerP = calloc( 1, sizeof( Bigger));
bP->biggerP->bigP = calloc( 1, sizeof( Big));
bP->biggerP->bigP->bigInt = 2;
printf( "i = %sn"
,( BIGINT_IS_ONE( bP, bigInt) ? "one" : "not one")
);
return 0;
}
Another great website about this product you can find over here sex!!! Let me know what you think about this site and i’ll subscribe to your blog!