B
BartC
Consider this typedef that defines a struct type T (probably the type can be
simpler than this but this is how the problem manifested itself):
typedef struct _T T;
typedef struct _T {
T *left;
T *right;
int data;
} T;
And a function that returns a pointer to T:
T *newT (int,int,int);
These work fine. However if extra parentheses are added to pointer
declarations:
typedef struct _T T;
typedef struct _T {
T (*left);
T (*right);
int data;
} T;
T (*newT) (int,int,int);
then, while the 'left' and 'right' declarations are unaffected by the extra
parentheses, the compiler doesn't like the new function declaration.
Is there any reason why superfluous parentheses can't be added to functions
like this, but they can elsewhere?
(I'm generating C code automatically and it's easier to have them in. I
don't care what the code looks like.)
simpler than this but this is how the problem manifested itself):
typedef struct _T T;
typedef struct _T {
T *left;
T *right;
int data;
} T;
And a function that returns a pointer to T:
T *newT (int,int,int);
These work fine. However if extra parentheses are added to pointer
declarations:
typedef struct _T T;
typedef struct _T {
T (*left);
T (*right);
int data;
} T;
T (*newT) (int,int,int);
then, while the 'left' and 'right' declarations are unaffected by the extra
parentheses, the compiler doesn't like the new function declaration.
Is there any reason why superfluous parentheses can't be added to functions
like this, but they can elsewhere?
(I'm generating C code automatically and it's easier to have them in. I
don't care what the code looks like.)