Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
June 04, 2005 templates in libraries | ||||
---|---|---|---|---|
| ||||
I have a library with one template function in it template array_case(T) { void array_change_key_case ( T[ char [] ] map) { foreach ( inout char [] keys;map.keys ) { keys = std.string.tolower(keys ); } } } However when I build the lib, I get the error Symbol Undefined _D3phd5array13array_case_Aa21array_change_key_caseFHAaAaZv If i eliminate the template and just make them functions it works fine. What is the rule with templates in libraries, I have to call the template somewhere in the code for it to generate stuff or ? Charlie |
June 04, 2005 Re: templates in libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charlie | Charlie wrote: > I have a library with one template function in it > > template array_case(T) > { > > void array_change_key_case ( T[ char [] ] map) > { > > foreach ( inout char [] keys;map.keys ) > { > > keys = std.string.tolower(keys ); > > } > > > } > > } > > > > However when I build the lib, I get the error > > Symbol Undefined _D3phd5array13array_case_Aa21array_change_key_caseFHAaAaZv > > If i eliminate the template and just make them functions it works fine. > > What is the rule with templates in libraries, I have to call the template > somewhere in the code for it to generate stuff or ? > > > Charlie > > Is the template in a file by itself? I reported this problem earlier; see post "Hair-pulling, D, and Optlink" Walter game the solution for dealing with this very real shortcoming in OMF libraries containing templates: http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/23701 I imagine that's what your problem was. -JJR |
June 04, 2005 Re: templates in libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | Hey John, That did work thanks :). I remember reading something about this but forget the title. This is pretty rough , I wonder though is OMF the only format that suffers from this ? I don't know enough about C++ templates to guess how they do it . Charlie "John Reimer" <brk_6502@yahoo.com> wrote in message news:d7t782$a6t$1@digitaldaemon.com... > Charlie wrote: > > I have a library with one template function in it > > > > template array_case(T) > > { > > > > void array_change_key_case ( T[ char [] ] map) > > { > > > > foreach ( inout char [] keys;map.keys ) > > { > > > > keys = std.string.tolower(keys ); > > > > } > > > > > > } > > > > } > > > > > > > > However when I build the lib, I get the error > > > > Symbol Undefined _D3phd5array13array_case_Aa21array_change_key_caseFHAaAaZv > > > > If i eliminate the template and just make them functions it works fine. > > > > What is the rule with templates in libraries, I have to call the template > > somewhere in the code for it to generate stuff or ? > > > > > > Charlie > > > > > > Is the template in a file by itself? > > I reported this problem earlier; see post "Hair-pulling, D, and Optlink" > > Walter game the solution for dealing with this very real shortcoming in OMF libraries containing templates: > > http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/23701 > > I imagine that's what your problem was. > > -JJR |
June 04, 2005 Re: templates in libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | An 'slightly' better soloution is to put that int* call in a mixin int comdatKludge = 0; template kludge () { int * kludge = &comdatKludge; } into the library, then the client just calls mixin kludge; "John Reimer" <brk_6502@yahoo.com> wrote in message news:d7t782$a6t$1@digitaldaemon.com... > Charlie wrote: > > I have a library with one template function in it > > > > template array_case(T) > > { > > > > void array_change_key_case ( T[ char [] ] map) > > { > > > > foreach ( inout char [] keys;map.keys ) > > { > > > > keys = std.string.tolower(keys ); > > > > } > > > > > > } > > > > } > > > > > > > > However when I build the lib, I get the error > > > > Symbol Undefined _D3phd5array13array_case_Aa21array_change_key_caseFHAaAaZv > > > > If i eliminate the template and just make them functions it works fine. > > > > What is the rule with templates in libraries, I have to call the template > > somewhere in the code for it to generate stuff or ? > > > > > > Charlie > > > > > > Is the template in a file by itself? > > I reported this problem earlier; see post "Hair-pulling, D, and Optlink" > > Walter game the solution for dealing with this very real shortcoming in OMF libraries containing templates: > > http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/23701 > > I imagine that's what your problem was. > > -JJR |
June 05, 2005 Re: templates in libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charlie | In article <d7takf$c4j$1@digitaldaemon.com>, Charlie says... > >An 'slightly' better soloution is to put that int* call in a mixin > >int comdatKludge = 0; >template kludge () >{ > > int * kludge = &comdatKludge; > >} > >into the library, then the client just calls > >mixin kludge; Hopefully Walter is able to find a fix for this problem at some point. I've added some more information to http://www.prowiki.org/wiki4d/wiki.cgi?DocComments/Template to help explain the problem and some possible solutions (basically, I cut-and-pasted some of these posts into the Wiki). jcc7 |
June 05, 2005 Re: templates in libraries | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charlie | Charlie wrote:
> An 'slightly' better soloution is to put that int* call in a mixin
>
> int comdatKludge = 0;
> template kludge ()
> {
>
> int * kludge = &comdatKludge;
>
> }
>
> into the library, then the client just calls
>
> mixin kludge;
>
>
Yeah... that does look a little cleaner! Nice one!
Although it does advertise the fact that their is a kludge! :-)
-JJR
|
Copyright © 1999-2021 by the D Language Foundation