https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106672
Bug ID: 106672
Summary: support Apple's old __private_extern__ keyword
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: egallager at gcc dot gnu.org
Reporter: egallager at gcc dot gnu.org
CC: iains at gcc dot gnu.org
Target Milestone: ---
Back when Apple had its own version of GCC it supported a __private_extern__
keyword, and clang still supports this keyword, albeit with a deprecation
warning:
$ clang -c __private_extern__.c
__private_extern__.c:1:24: warning: use of __private_extern__ on a declaration
may not produce external symbol private to the linkage unit and is deprecated
[-Wprivate-extern]
__private_extern__ int foo;
^
__private_extern__.c:1:24: note: use __attribute__((visibility("hidden")))
attribute instead
1 warning generated.
$
Meanwhile, GCC rejects the same code with:
$ /usr/local/bin/gcc -c __private_extern__.c
__private_extern__.c:1:19: error: expected ';' before 'int'
1 | __private_extern__ int foo;
| ^~~~
| ;
$
While __private_extern__ should no longer be used in new code, there is still
some old code out there with __private_extern__ in it that one may wish to
compile. Some projects hack around this by adding
-D__private_extern__=__attribute__\(\(__visibility__\("hidden"\)\)\) to their
compile flags, but it would be easier if GCC just handled this automatically. I
am self-assigning, although it may take me awhile to get to, so if someone else
thinks they can do this first, feel free to take it from me.