Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Do all declarations for the same static function or variable have to include the storage class static?

class function static storage
0
Posted

Do all declarations for the same static function or variable have to include the storage class static?

0

The language in the Standard does not quite require this (what’s most important is that the first declaration contain static), but the rules are rather intricate, and are slightly different for functions than for data objects. (There has also been a lot of historical variation in this area.) Therefore, it’s safest if static appears consistently in the definition and all declarations. Additional links: An article by Jutta Degener explaining the subtly different rules for static variables versus static functions. References: ISO Sec. 6.1.2.2 Rationale Sec. 3.1.2.2 H&S Sec. 4.3 p.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.