Thread overview | |||||
---|---|---|---|---|---|
|
November 23, 2005 Template issue? | ||||
---|---|---|---|---|
| ||||
I understand there's some issue regarding the use of Template code from a library? The Boxer template comes to mind ~ something to do with debug vs non-debug compiles? Could someone explain the issue, please? And how one might get around it? Thx |
November 23, 2005 Re: Template issue? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | Kris wrote:
> I understand there's some issue regarding the use of Template code from a library? The Boxer template comes to mind ~ something to do with debug vs non-debug compiles?
>
> Could someone explain the issue, please? And how one might get around it?
The issue I've encountered has to do with contracts and asserts. DMD generates function calls for this stuff, and since templates are generated when the client code is compiled, the client code may or may not expect these functions to exist during the linking phase. Probably not a big deal if you're willing to provide debug and release builds of your library, but this was a problem for Ares because it is linked implicitly. The workaround I used was to build modules containing template code without the -release flag set. This worked out fairly well for Ares because the modules containing template code only contain template code, so the result was an object file that contained only the compiler-generated contract and assert functions. Then when the client compiles the actual template code is generared according to whatever compiler options he specifies, which may include inlining and such, and the contract functions are available for linking should they be necessary. It's not an ideal solution, but it seems sufficient if you're willing to live with the template-only module rule.
Sean
|
November 24, 2005 Re: Template issue? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | Very helpful. Thanks, Sean. "Sean Kelly" <sean@f4.ca> wrote in message news:dm2i1m$1o4b$1@digitaldaemon.com... > Kris wrote: >> I understand there's some issue regarding the use of Template code from a library? The Boxer template comes to mind ~ something to do with debug vs non-debug compiles? >> >> Could someone explain the issue, please? And how one might get around it? > > The issue I've encountered has to do with contracts and asserts. DMD generates function calls for this stuff, and since templates are generated when the client code is compiled, the client code may or may not expect these functions to exist during the linking phase. Probably not a big deal if you're willing to provide debug and release builds of your library, but this was a problem for Ares because it is linked implicitly. The workaround I used was to build modules containing template code without the -release flag set. This worked out fairly well for Ares because the modules containing template code only contain template code, so the result was an object file that contained only the compiler-generated contract and assert functions. Then when the client compiles the actual template code is generared according to whatever compiler options he specifies, which may include inlining and such, and the contract functions are available for linking should they be necessary. It's not an ideal solution, but it seems sufficient if you're willing to live with the template-only module rule. > > > Sean |
Copyright © 1999-2021 by the D Language Foundation