[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: compile problem on older program


tomas@tuxteam.de wrote:
> https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html

But my example code has no nested functions.
The two functions are disjoint. The main() function only contains
a type declaration by function prototype, not the function body.

I can change the code to plain K&R C and gcc still fails:

  static int bla(x)
  int x;
   return (x != 1);
  int main()
   static int bla();

I found a quote in
  "The C standard contains the following. n1570/S6.7.1/7:
   The declaration of an identifier for a function that has block scope
   shall have no explicit storage-class specifier other than extern."

I have N1548, which bears the same statement in 6.7.1 as subparagraph 6.
This paragraph refers to "typedef", "extern", "static", "_Thread_local",
"auto", and "register".
A declaration within a function body has block scope, indeed.
(6.2.1 subparagraph 4.)

So gcc is right when it refuses on "static". The obviousily once existing
tolerance was inappropriate.
I still wonder whether the forbidden storage classes would cause semantic
problems, or whether they shall stay reserved for future use.

Have a nice day :)


Reply to: