J
John Taylor
Hello,
I'm reading the C99 standard. I have a doubt about declarations, in
particular function declarations. I know it is not possible to put an
initializer inside a function declaration, but I cannot find the point
in the standard that forbids it. For example if I try to compile a
minimal C99 program containing the following declaration:
int add(int a, int b) = 5;
I get the following error message:
error: function ‘add’ is initialized like a variable
But by applying the BNF syntax description, I can say that "5" is an
<initializer>, "add(int a, int b)" is a <declarator>, "add(int a, int b)
= 5" is an <init-declarator>, "int" is a <declaration-specifiers> and so
"int add(int a, int b) = 5" is a <declaration>.
What's wrong with my reasoning?
Thanks.
I'm reading the C99 standard. I have a doubt about declarations, in
particular function declarations. I know it is not possible to put an
initializer inside a function declaration, but I cannot find the point
in the standard that forbids it. For example if I try to compile a
minimal C99 program containing the following declaration:
int add(int a, int b) = 5;
I get the following error message:
error: function ‘add’ is initialized like a variable
But by applying the BNF syntax description, I can say that "5" is an
<initializer>, "add(int a, int b)" is a <declarator>, "add(int a, int b)
= 5" is an <init-declarator>, "int" is a <declaration-specifiers> and so
"int add(int a, int b) = 5" is a <declaration>.
What's wrong with my reasoning?
Thanks.