Re: Exporting CString from a DLL
- From: "EricW" <empty@xxxxxxxxx>
- Date: Fri, 29 Feb 2008 10:54:57 -0500
Hi All,
Thanks for the feedback. While I did get it to work (yes, by modifying
atlstr.h, ick) I'm going to back off of it for many of the reasons you
pointed out and try the stdafx.h approach. I've never changed a standard
header file to fix a problem and I don't want to start now. If you happen
to know anyone on the compiler team and can give them a nudge to smooth out
STL and DLL interaction that would be great,... yeah, I know I'm dreaming
there :).
Thanks again,
Eric
"Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote in message
news:77aes3p18ggv0jqhpiagac3puiq7qk244a@xxxxxxxxxx
On Thu, 28 Feb 2008 15:24:37 -0500, "EricW" <empty@xxxxxxxxx> wrote:
Hi Doug,
I went with the solution of deriving a new class from CString because
the
MSDN article below suggested that is the best approach.
It isn't for the reason I gave.
It also seemed to
suggest the changing of atlstr.h/afxstr.h was required to make this work
completely which I'd greatly prefer not to do but without that you'll get
duplicate definitions.
You should have listened to your instinct. :)
Also I did do something like you suggested in making
a macro for __declspec( ? ) originally I just left it out for time.
Anyway,
I think I can live with the solution of modifying atlstr.h for now until
something better comes along.
The only reason I would ever touch a standard header would be to fix a
bug,
and even then, I'd look long and hard for a workaround that does not
require touching a standard header. It appears you're doing this not to
fix
a bug, but to derive a new class, like it's a standard design technique;
it's not. Besides having to figure out these linker errors you're getting
now, you're creating a maintenance nightmare, because you're going to have
to alter this header every time you install VC, inspect it after applying
service packs, and so forth, and anyone you give your code to will have to
do the same thing. Then are the compatibility problems you may
inadvertently introduce.
Thanks,
EricW
http://msdn2.microsoft.com/en-us/library/ms174286(VS.80).aspx
The only advice on that page that may be worth taking is, "For more
information on this issue, see the Knowledge Base article, "Linking Errors
When you Import CString-derived Classes" (Q309801)"
http://support.microsoft.com/kb/309801
At least it tells you to modify your stdafx.h file instead of a standard
header. Both articles use the wrong macro for selecting the __declspec
flavor, the MSDN article using AFX_EXT_CLASS, and the KB article _USRDLL;
see my previous message for the one correct method. Again, your best bet
is
to forget about deriving from CString and extend its interface through
non-member functions.
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: Exporting CString from a DLL
- From: Doug Harrison [MVP]
- Re: Exporting CString from a DLL
- References:
- Exporting CString from a DLL
- From: EricW
- Re: Exporting CString from a DLL
- From: Doug Harrison [MVP]
- Re: Exporting CString from a DLL
- From: EricW
- Re: Exporting CString from a DLL
- From: Doug Harrison [MVP]
- Exporting CString from a DLL
- Prev by Date: Re: Problem when defining my own string.h
- Next by Date: Re: start array at index 1 instead of 0
- Previous by thread: Re: Exporting CString from a DLL
- Next by thread: Re: Exporting CString from a DLL
- Index(es):
Relevant Pages
|