ITEM: E3130L
xlc complains against static fun. decl. within fun.
Question:
I have an RS/6000 running 3.2.4 and am trying to port some C code to
it from SUN and HP. There are instances in my code where a function
is declared as static within another function. HP and SUN compilers
didn't complain about this, but xlc does. When I remove this
declaration from within the function and declare it globally (i.e. I
make a global declaration for a static function) it works fine. Why
does this happen?
Response:
xlc is a strict ANSI compiler. According to section 3.5.1 of the
C ANSI X3.159-1989 standard, "The declaration of an identifier for a function
that has block scope shall have no explicit storage-class specifier other than
extern." Anything declared inside a function has block scope, so you can't use
the static storage-class specifier on a nested function declaration. There are
two ways to get rid of the error:
1. Move the static function declarations out of the enclosing function
so they are at file scope.
2. Remove the static storage-class specifier from all declarations and
from the definition.
Since xlc is a strict ANSI compiler, there is no compiler option to get around
this problem.
Support Line: xlc complains against static fun. decl. within fun. ITEM: E3130L
Dated: October 1993 Category: N/A
This HTML file was generated 99/06/24~13:30:54
Comments or suggestions?
Contact us