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

Dmitri Gribenko gribozavr at gmail.com
Sat Apr 6 12:19:32 PDT 2013


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:

$ clang weak.c
weak.c:5:8: error: call to 'PFoo' is ambiguous
return PFoo(1);
       ^~~~
weak.c:1:12: note: candidate function
extern int PFoo(int);
           ^
weak.c:2:14: note: candidate function
#pragma weak PFoo = Foo
             ^
1 error generated.

Is this an error on Clang's side?

Dmitri

--
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