c - Why can't auto, static keyword be used in formal parameter in function definitions? -


compiler - mingw gcc os - windows 10

statement 1:

void fun(auto int a){} // statement 1 - error! 

statement 2:

void fun(static int a){} // statement 2- error! 

statement 3:

static void fun(auto int a){} //statement 3- error! 

statement 4:

void fun(register int a){} // statement 4-no error(valid) 

why statements 1,2 , 3 generate compile time errors statement 4 not?

what problem while using auto in formal parameters in function?

here error output:

error: storage class specified parameter 'a' void fun(auto int a)

because standard says so. see 6.7.6.3p2:

the storage-class specifier shall occur in parameter declaration register.

storage class specifiers don't make sense function parameters.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -