Reputation: 106012
Regarding the statement;
Every object declaration in C and C++ has two principal parts: a sequence of zero or more declaration specifiers, and a sequence of one or more declarators, separated by commas. For example:
Does zero specifier means declaring a variable named a
as
a;
and not
int a;
? I tried this with an example
#include <stdio.h>
int main(){
x = 9;
printf("%d\n", x);
return 0;
}
and this is giving an error:
[Error] 'x' undeclared (first use in this function)
Upvotes: 1
Views: 189
Reputation: 145839
It was possible in c89 with the implicit int
rule but you needed at least a qualifer or a storage class specifier.
auto x = 3; /* allowed in c89, not valid in c99 */
static y = 4; /* allowed in c89, not valid in c99 */
const z = 5; /* allowed in c89 , not valid in c99*/
a; /* not valid in c89, c99 without a prior declaration */
b = 6; /* not valid in c89, c99 without a prior declaration */
Upvotes: 2
Reputation: 224944
Wherever you got that statement from, it's wrong. You have to have at least one declaration-specifier for a declaration to be valid. Here's the relevant bit from the standard (it's an image because I couldn't make markdown behave):
Upvotes: 1