https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80785

--- Comment #2 from Daniel Gutson <daniel.gutson at intel dot com> ---
(In reply to Jonathan Wakely from comment #1)
> (In reply to Daniel Gutson from comment #0)
> > I don't see why one would want to do this.
> 
> You might have a header that encloses the entire contents in an extern "C"
> language linkage block, and it might contain static variables.
> 
> Variables with internal linkage don't have language linkage, so the extern
> "C" doesn't do anything, but isn't necessarily a mistake.

I still think that a warning would help. With this aid, the programmer may pull
the static definitions out of the extern"C" block, or more importantly,
refactor the organization of the header files structure. Opt-in -Wextern-static
or alike?

> 
> For function definitions it's not contradictory, and not redundant:
> 
> extern "C" static void f() { }
> static void g() { }
> 
> f() and g() both have internal linkage, but have different types. This
> matters if you want to pass &f to a function that takes a pointer to a
> function with "C" language linkage (N.B. GCC and many other compilers don't
> implement this correctly, see PR 2316).

OK, didn't think about this use case.

Reply via email to