[cfe-dev] 'pragma weak' redeclaration as extern function

Dmitri Gribenko gribozavr at gmail.com
Sat Apr 6 13:50:36 PDT 2013


On Sat, Apr 6, 2013 at 10:19 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> Hello,
>
> GCC 4.7.2 compiles the following program:
>
> extern int PFoo(int);
> #pragma weak PFoo = Foo
> int Foo(int a) { return a; }
> int main() {
>   return PFoo(1);
> }
>
> while Clang emits an error:

+ Eli Friedman, who committed initial support for pragma weak and commented:
http://llvm.org/bugs/show_bug.cgi?id=3679#c16

> the supported form is the following:
>
> extern void g2;
> #pragma weak g2 = g1
>
> Basically, the #pragma weak can't introduce a new name, but it can alias an existing name to a name that isn't defined yet.

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-dev mailing list