using std::string in my dll-exported class 
Author Message
 using std::string in my dll-exported class

Hi!

I am having a data class being exported from a dll.
Within this class there is a member of type std::string.

Compiling the dll give me a warning of
    "
    warning C4251:
    'm_strName' : class 'std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >'
    needs to have dll-interface to be used by clients of class
    "

Ignoring this warning presents me an error, but only when I assign the
std::string for a second time!
(
I have an inline setter member
    "void setName( std::string strName ) { m_strName = strName; }"
in my class.
)

Explicitly instantiating std:::string as mentioned in Q168958 does NOT work,
as it IS instantiated already.

What do I make wrong?

Thanks and Happy Easter, Pi.



Thu, 02 Oct 2003 21:52:59 GMT  
 using std::string in my dll-exported class
Thanks, I was a little "dull" I suppose.
Another answer above ("Markus Sch?pflin" on "Dll returning string causes
test application to crash")
helped me with MY problem, too:
I obviously WAS using differnet heaps as my dll was "not using MFC" whereas
my App definitely DOES
use MFC (dynamically linked)...

So here's my afterburner question:
Why does this solve my problem? Why do I have to "use MFC" to have access to
the STL?
Or does this come from using different Runtime Libraries if I do or don't
use the MFC?

Regards, Pi.



Thu, 02 Oct 2003 22:02:06 GMT  
 using std::string in my dll-exported class

Quote:

> Thanks, I was a little "dull" I suppose.
> Another answer above ("Markus Sch?pflin" on "Dll returning string causes
> test application to crash")
> helped me with MY problem, too:
> I obviously WAS using differnet heaps as my dll was "not using MFC" whereas
> my App definitely DOES
> use MFC (dynamically linked)...

> So here's my afterburner question:
> Why does this solve my problem? Why do I have to "use MFC" to have access to
> the STL?
> Or does this come from using different Runtime Libraries if I do or don't
> use the MFC?

You don't need to use MFC. You need to link to the DLL version of the
runtime library (Project|Settings|C++|Code Generation, and in "Use
run-time library" select "Multithreaded DLL" or "Debug Multithreaded
DLL")

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)



Fri, 03 Oct 2003 00:15:41 GMT  
 using std::string in my dll-exported class
See below...



Quote:

> > Thanks, I was a little "dull" I suppose.
> > Another answer above ("Markus Sch?pflin" on "Dll returning string causes
> > test application to crash")
> > helped me with MY problem, too:
> > I obviously WAS using differnet heaps as my dll was "not using MFC"
whereas
> > my App definitely DOES
> > use MFC (dynamically linked)...

> > So here's my afterburner question:
> > Why does this solve my problem? Why do I have to "use MFC" to have
access to
> > the STL?
> > Or does this come from using different Runtime Libraries if I do or
don't
> > use the MFC?

> You don't need to use MFC. You need to link to the DLL version of the
> runtime library (Project|Settings|C++|Code Generation, and in "Use
> run-time library" select "Multithreaded DLL" or "Debug Multithreaded
> DLL")

> --
> Pete Becker
> Dinkumware, Ltd. (http://www.dinkumware.com)

You mean I can use MFC in one DLL and don't have to use MFC in the other
one?
Ok, I'll try this...
Thanks, Pi.


Sat, 04 Oct 2003 13:24:25 GMT  
 using std::string in my dll-exported class
Bingo!
You were right (not that I didn't believe, but I wanted to try first...;-))
Thanks a lot, Pi.


Sat, 04 Oct 2003 13:30:36 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. problem using std::string in exported class to be puit in a DLL

2. using std::string and vector in DLL exported class

3. export classes using std namespace (ex std::vector) in a DLL

4. Exporting a class CONTAINING an std::string

5. Need help exporting std::string from dll

6. How to export a std::string from a DLL

7. std::string and DLL exports

8. Exporting string from dll using non DLL version of CRT

9. using std::string with windows classes gives error

10. problem using std::string as base class

11. Calling an unmanaged DLL function that uses a std::string parameter

12. Problem returning an std::string from a DLL (using VC7)

 

 
Powered by phpBB® Forum Software