Thread overview | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 23, 2004 [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Pre v0.81 this would link correctly: class Token { extern (C) int memcmp (void *, void *, uint); void test() { memcmp (..., ..., ...); } } with v0.81, the linker fails with: Error 42: Symbol Undefined __D5hello5Token6memcmpUPvPvkZi If I move the extern (C) declaration outside of the class definition (up to the global scope) it links correctly: extern (C) int memcmp (void *, void *, uint); class Token { void test() { memcmp (..., ..., ...); } } Was this an intended change of symbol naming? |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | In article <c3ptjf$1tg5$1@digitaldaemon.com>, Kris says... > >Pre v0.81 this would link correctly: > >class Token >{ > extern (C) int memcmp (void *, void *, uint); > > void test() > { > memcmp (..., ..., ...); > } >} > >with v0.81, the linker fails with: > >Error 42: Symbol Undefined __D5hello5Token6memcmpUPvPvkZi > >If I move the extern (C) declaration outside of the class definition (up to >the global scope) it links correctly: > >extern (C) int memcmp (void *, void *, uint); > >class Token >{ > void test() > { > memcmp (..., ..., ...); > } >} > >Was this an intended change of symbol naming? > > I do use extern(C) inside the class definition but I thought the method had to be static. all my extern(C) inside the class are static and still compile and link with 0.81 Ant |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | Same here. Requires the static keyword for methods. C On Tue, 23 Mar 2004 17:57:10 +0000 (UTC), Ant <Ant_member@pathlink.com> wrote: > In article <c3ptjf$1tg5$1@digitaldaemon.com>, Kris says... >> >> Pre v0.81 this would link correctly: >> >> class Token >> { >> extern (C) int memcmp (void *, void *, uint); >> >> void test() >> { >> memcmp (..., ..., ...); >> } >> } >> >> with v0.81, the linker fails with: >> >> Error 42: Symbol Undefined __D5hello5Token6memcmpUPvPvkZi >> >> If I move the extern (C) declaration outside of the class definition (up to >> the global scope) it links correctly: >> >> extern (C) int memcmp (void *, void *, uint); >> >> class Token >> { >> void test() >> { >> memcmp (..., ..., ...); >> } >> } >> >> Was this an intended change of symbol naming? >> >> > > I do use extern(C) inside the class definition but I > thought the method had to be static. > all my extern(C) inside the class are static and still > compile and link with 0.81 > > Ant > > -- D Newsgroup. |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ant | In article <c3ptpm$1tto$1@digitaldaemon.com>, Ant says... > >In article <c3ptjf$1tg5$1@digitaldaemon.com>, Kris says... >> >>Pre v0.81 this would link correctly: >> >>class Token >>{ >> extern (C) int memcmp (void *, void *, uint); >> >> void test() >> { >> memcmp (..., ..., ...); >> } >>} >> >>with v0.81, the linker fails with: >> >>Error 42: Symbol Undefined __D5hello5Token6memcmpUPvPvkZi >> >>If I move the extern (C) declaration outside of the class definition (up to >>the global scope) it links correctly: >> >>extern (C) int memcmp (void *, void *, uint); >> >>class Token >>{ >> void test() >> { >> memcmp (..., ..., ...); >> } >>} >> >>Was this an intended change of symbol naming? >> >> > >I do use extern(C) inside the class definition but I >thought the method had to be static. >all my extern(C) inside the class are static and still >compile and link with 0.81 > >Ant > > That was the first thing I tried, but that didn't work either. ------------------- Carlos Santander B. |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | That actually was a bug fixed in the compiler. The memcmp() declaration is declared as a virtual member function of Token with the C calling convention. It really should be moved outside of the class, or declared as static. "Kris" <someidiot@earthlink.net> wrote in message news:c3ptjf$1tg5$1@digitaldaemon.com... > Pre v0.81 this would link correctly: > > class Token > { > extern (C) int memcmp (void *, void *, uint); > > void test() > { > memcmp (..., ..., ...); > } > } > > with v0.81, the linker fails with: > > Error 42: Symbol Undefined __D5hello5Token6memcmpUPvPvkZi > > If I move the extern (C) declaration outside of the class definition (up to > the global scope) it links correctly: > > extern (C) int memcmp (void *, void *, uint); > > class Token > { > void test() > { > memcmp (..., ..., ...); > } > } > > Was this an intended change of symbol naming? > > |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> That actually was a bug fixed in the compiler. The memcmp() declaration is
> declared as a virtual member function of Token with the C calling
> convention. It really should be moved outside of the class, or declared as
> static.
Wouldn't a static method still be name-mangled? If it is then linking to memcmp still won't work, right?
And if it isn't mangled then I think this is another bug. Otherwise you wouldn't be able to have static functions with the same name in different classes!
Hauke
|
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hauke Duden | In article <c3q0qd$233o$1@digitaldaemon.com>, Hauke Duden says... > >Walter wrote: >> That actually was a bug fixed in the compiler. The memcmp() declaration is declared as a virtual member function of Token with the C calling convention. It really should be moved outside of the class, or declared as static. > >Wouldn't a static method still be name-mangled? If it is then linking to memcmp still won't work, right? > >And if it isn't mangled then I think this is another bug. Otherwise you wouldn't be able to have static functions with the same name in different classes! > >Hauke Actually, that's what I was saying in my other post. Indeed, the linker complains and reports a name-mangled function. ------------------- Carlos Santander B. |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Carlos Santander B. | As Carlos says: even if it's static within the class it will still be name-mangled. The only solution is apparently to move such declarations up to module-scope. - Kris "Carlos Santander B." <Carlos_member@pathlink.com> wrote in message news:c3q12m$23eb$1@digitaldaemon.com... > In article <c3q0qd$233o$1@digitaldaemon.com>, Hauke Duden says... > > > >Walter wrote: > >> That actually was a bug fixed in the compiler. The memcmp() declaration is > >> declared as a virtual member function of Token with the C calling convention. It really should be moved outside of the class, or declared as > >> static. > > > >Wouldn't a static method still be name-mangled? If it is then linking to memcmp still won't work, right? > > > >And if it isn't mangled then I think this is another bug. Otherwise you wouldn't be able to have static functions with the same name in different classes! > > > >Hauke > > Actually, that's what I was saying in my other post. Indeed, the linker complains and reports a name-mangled function. > > ------------------- > Carlos Santander B. |
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | Kris schrieb:
> As Carlos says: even if it's static within the class it will still be
> name-mangled. The only solution is apparently to move such declarations up
> to module-scope.
>
> - Kris
All declarations are name mangled in D, because they are mangled with module name and arguments. Exceptions are all declarations with extern(C/Pascal/Windows/...) sorts where name mangling is to be turned off. Always, not depending on whether it's a static member or module scope level. Obviously, making non-static members or inner functions extern is unfeasible.
-eye
|
March 23, 2004 Re: [BUG] extern (C) behavior changed in v0.81 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hauke Duden | "Hauke Duden" <H.NS.Duden@gmx.net> wrote in message news:c3q0qd$233o$1@digitaldaemon.com... > Walter wrote: > > That actually was a bug fixed in the compiler. The memcmp() declaration is > > declared as a virtual member function of Token with the C calling convention. It really should be moved outside of the class, or declared as > > static. > > Wouldn't a static method still be name-mangled? It shouldn't be. > If it is then linking to > memcmp still won't work, right? I'll check into it. > And if it isn't mangled then I think this is another bug. Otherwise you wouldn't be able to have static functions with the same name in different classes! That doesn't work in C++, either <g>. You can only have one function with a particular name and C linkage in the entire program. |
Copyright © 1999-2021 by the D Language Foundation