Re: A solution to warning C4251 - class needs to have dll-interface...?




"Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote in message
news:i4rch35fuvcdpl8jn7skubsf3v7rl8qph8@xxxxxxxxxx
On Wed, 17 Oct 2007 19:22:37 +0200, "Niels Dekker - no return address"
<unknown@xxxxxxxxxxxxxxx> wrote:

It sounds like this scenario won't happen when using an STL container
within
my dllexported class, right? Because the functions of the STL containers
are completely defined by their header files. We're using both VC++ 7.1
and
8.0, with the included STL.

[snip]

Note that sharing C++ objects in this way between modules must be
considered equivalent to static linking for compilation dependency
purposes. In particular, all the modules should be compiled with the same
options, and they must all use the same CRT DLL. It is very important to
understand this, because otherwise, each module will end up with its own
CRT state, including heap, file descriptors, and so forth, and you won't
be
able to fully share C++ objects between modules. For example, if modules X
and Y use different CRTs, you won't be able to delete an object in one
that
was created by the other.

The poster is using different CRT (different VC++ versions). Moreover, it's
different STL headers as well, so there will be ODR violations and therefore
runtime failures.


--
Doug Harrison
Visual C++ MVP


.



Relevant Pages

  • Re: A solution to warning C4251 - class needs to have dll-interface...?
    ... Because the functions of the STL containers ... are completely defined by their header files. ... the static data for the entire program. ...
    (microsoft.public.vc.language)
  • Re: latest STL
    ... > Since it is to my knowledge that the entire STL comes as a collection ... > downloading the latest version of the respective header files (I'm ... Or do I have to upgrade gcc itself ...
    (comp.os.linux.development.apps)
  • Re: standard template library
    ... there is like 50 header files, which of those are STL? ... Why do you care? ... -- RFC 1925 ...
    (microsoft.public.vc.language)
  • Re: wtf wrong with msdn in .net 2003? I cant find stuff I _know_ is there..
    ... does not want anyone to use STL. ... the only thing i can do is browse through the actual header files and check ... instead promoting their own MFC cruft. ... > And I hate it when I hit F1 to get help on some Win API function and ...
    (microsoft.public.dotnet.languages.vc)
  • latest STL
    ... computer because it had an outdated version of the STL vector which ... Since it is to my knowledge that the entire STL comes as a collection ... downloading the latest version of the respective header files (I'm ... Or do I have to upgrade gcc itself ...
    (comp.os.linux.development.apps)