§6.7.6.3 Function declarators
2) The only storage-class specifier that shall occur in a parameter declaration is register.
§6.7.6.3 Function declarators
13) The storage-class specifier in the declaration specifiers for a parameter declaration, if present, is ignored unless the declared parameter is one of the members of the parameter type list for a function definition.
I have declared and defined like this...
int function(static int param)
{
return param;
}
Visual Studio is throwing a warning. What I understood is, if we use register as a parameter type in the declaration of a function, it should compile without warning. Other than register, it will ignore the storage class and throw a warning message to user.
Is my understanding proper?
Thanks
I believe 6.7.6.3 is saying that storage-class specifiers are ignored in function declarations; it says that it's ignored unless the parameter is part of the parameter type list for a function definition. Since you're showing a function definition, it would not be proper for the compiler to ignore this invalid storage-class specifier here.
First of all the compiler that you get with Visual Studio is not according to c99/c11 standard.
The function definition should not allow the use of storage class specifiers other than register. It should flag it as a bad use of storage class. As stated, VS compiler is not according to standard, it is throwing a warning message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With