A tutorial said
You cannot declare functions within a block as static.
What is the reason?How does it affect the function?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
staticwhen applied to functions means that the function has internal linkage. i.e. it can be accessed within this file only. In other words it has file-scope. This linkage applies irrespective of whether you declare a function inside another function or outside of all of them.Now, if you apply the
statickeyword to a function declaration inside another block/function, semantically speaking, you are trying to restrict the scope of the function to that particular block/function, which goes against the language rules that state thatstaticfunctions, irrespective of their place of declaration, shall have file-scope.And hence, the standard might be prohibiting such a declaration.
PS: Footnote
30in6.2.3in the latest C11 standard states-