$ cat foo.c
extern char *bar1 __attribute__((externally_visible));
char *bar1;
extern char *bar2 __attribute__((externally_visible));
char *bar2 __attribute__((externally_visible));
extern char *bar3;
char *bar3 __attribute__((externally_visible));
char *bar4 __attribute__((externally_visible));
char *bar5;
extern char *bar5 __attribute__((externally_visible));
$ gcc -O -fwhole-program -c -o foo.o foo.c
foo.c:1: warning: externally_visible attribute have effect only on public
objects
foo.c:4: warning: externally_visible attribute have effect only on public
objects
foo.c:13: warning: externally_visible attribute have effect only on public
objects
$ nm -a foo.o | grep bar
00000004 C bar4
All five of these variables ought to be externally visible.
Note -fwhole-program.
Seen with:
(ppc) gcc version 4.1.1 20060525 (Red Hat 4.1.1-1.pr27898)
(ppc->i686) gcc version 4.1.0
--
Summary: externally_visible attribute not effective with prior
declaration of symbol.
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dwmw2 at infradead dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28744