Re: Scope of specifier extern



Christian Christmann wrote:
That's the point. I figured out that GCC is considering both 'e' as one
and the same object. However, I don't know if this strictly corresponds
to ANSI C-99.

I don't see why not. I mean from an implementation point of view
"extern int e" just means use the symbol defined globally somewhere
else. The fact that "somewhere else" is within the same object file
doesn't really matter.

It's similar in concept to a forward declaration, e.g.

int somefunc(int);
int myfunc(int x) { return somefunc(x); }
int somefunc(int x) { return x + 1; }

You could also write it as

int myfunc(int x) { extern int somefunc(int); return somefunc(x); }
int somefunc(int x) { return x + 1; }

"gcc -pedantic --std=c99 -O2 -Wall -W"

Doesn't raise a single diagnostic at that. :-)

Tom

.



Relevant Pages

  • Re: Fibonacci implementation
    ... Christian Christmann wrote: ... pseudo code ... static unsigned long fibo(unsigned int n) ... unsigned long pprev, prev, value; ...
    (comp.programming)
  • Re: Data flow analysis
    ... On Sun, 14 Jan 2007, Christian Christmann wrote: ... int function// 1 ... or a value previously written into 'x' by the assignment in line 3.) ...
    (comp.programming)
  • Re: Strange function use
    ... Christian Christmann wrote: ... int a, b, foo; ... int a, b, foo(int); ... foooccurs inside a declaration. ...
    (comp.lang.c)
  • Re: Function return type
    ... Christian Christmann wrote: ... C89 defines: main ... C99 defines: int main ... Best is: int main ...
    (comp.lang.c)
  • Re: Implicit declaration
    ... Christian Christmann said: ... int main ... When I compile this file, ... void test(int); ...
    (comp.lang.c)