[ 
https://issues.apache.org/jira/browse/QPID-5134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13769857#comment-13769857
 ] 

Andrew Stitcher commented on QPID-5134:
---------------------------------------

There is no absolute rule:
"The implementation of template functions must be available in accessible 
header files to enable the compiler to generate the code for the concrete type."

Where the implementation of template functions resides depends on the template 
instantiation model used.

For most of qpid we use an implicit instantiation model, but in a few places we 
explicitly instantiate templates used. For these functions we only have 
specialisations and no "fall back" general instantiation.

All that is required is to explicitly export the specialisations.
                
> Windows compile error - framing::Buffer::getUInt() not exported from dll
> ------------------------------------------------------------------------
>
>                 Key: QPID-5134
>                 URL: https://issues.apache.org/jira/browse/QPID-5134
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.24
>         Environment: Windows + proton
>            Reporter: Chuck Rolke
>
> In framing::Buffer.h
> {code}
>     template <int n>
>     QPID_COMMON_EXTERN uint64_t getUInt();
> {code}
> In framing::Buffer.cpp
> {code}
>     template <>
>     uint64_t Buffer::getUInt<1>() {
>         return getOctet();
>     }
>     template <>
>     uint64_t Buffer::getUInt<2>() {
>         return getShort();
>     }
>     ...
> {code}
> The code fails to link:
> {noformat}
> error LNK2019: unresolved external symbol 
>  "unsigned __int64 qpid::framing::Buffer::getUInt<4>(void)" 
> referenced in function 
>  "unsigned int qpid::broker::amqp::OutgoingFromQueue::Record::
>   getIndex(struct pn_delivery_tag_t)
> {noformat}
> In previous issues (QPID-2926) windows code has manually generated instances 
> of the template functions so that the DLL could export them. This time that 
> trick doesn't work.
> Is this code a violation of "The implementation of template functions must be 
> available in accessible header files to enable the compiler to generate the 
> code for the concrete type." ?
> For completeness there is also a failure sister Buffer::putUInt<n>() 
> functions. Probably the same fix would be good for both errors.
> I can think of some c-style solutions for this problem that would work 
> straight away...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to