For Programmers: Free Programming Magazines  


Home > Archive > VC Language > May 2006 > returning namespaced C++ class from a dll export









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author returning namespaced C++ class from a dll export
ultranet

2006-05-25, 7:08 pm

It appears returning CStringArray is possible, although it is a C++ type, but
returning some proprietary type, like Proprietary::RefPtr<Type> complains
about C linkage and C++ class. The only difference i'm seeing is the
namespace. Is that why it fails?

Thanks.
Carl Daniel [VC++ MVP]

2006-05-25, 7:08 pm

"ultranet" <ultranet@discussions.microsoft.com> wrote in message
news:A5CAB791-3FBB-43CF-BD28-EEFB464B9D9A@microsoft.com...
> It appears returning CStringArray is possible, although it is a C++ type,
> but
> returning some proprietary type, like Proprietary::RefPtr<Type> complains
> about C linkage and C++ class. The only difference i'm seeing is the
> namespace. Is that why it fails?


No, it has nothing to do with the namespace and everything to do with the
template.

If you try to export a template instantiation, the compiler will gripe
unless both the template and the type(s) the template is instantiated with
are all marked as __dllexport (in your example, Proprietary::RefPtr and Type
both need to be exported).

-cd


ultranet

2006-05-26, 7:09 pm



"Carl Daniel [VC++ MVP]" wrote:

> "ultranet" <ultranet@discussions.microsoft.com> wrote in message
> news:A5CAB791-3FBB-43CF-BD28-EEFB464B9D9A@microsoft.com...
>
> No, it has nothing to do with the namespace and everything to do with the
> template.
>
> If you try to export a template instantiation, the compiler will gripe
> unless both the template and the type(s) the template is instantiated with
> are all marked as __dllexport (in your example, Proprietary::RefPtr and Type
> both need to be exported).


But looking at MFC classes, they are not marked as __dllexport, though i do
realize that MFC used in shared dll necessarily implies that. Does the
compiler do that, or what am i missing?

Thanks.
Victor Bazarov

2006-05-26, 7:09 pm

ultranet wrote:
> [..]
> But looking at MFC classes, they are not marked as __dllexport,


You don't need to mark them if you have a DEF file, IIRC. See the
article "Exporting from a DLL Using DEF Files" in MSDN library.

> though i do realize that MFC used in shared dll necessarily implies
> that. Does the compiler do that, or what am i missing?


Well, take a look at the MFC building procedure[s] and you will see,
probably.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com