Re: Exporting CString from a DLL

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: Automatically generate variables
    ... Must be C by your definition since crapit might possibly be a header that makes it C. ... I knew it was *the* windows windows.h header because the ... Given certain assumptions the C code was valid C code, however from what I remember it certainly was not a C program solving the problem since it not only relied on non-C APIs but also relied on external programs that in general are *not* installed on machine. ... You, on the other hand, just said that it might be C even if it goes beyond what the standard defined and gave no outer limit on what could be considered C. ...
    (comp.lang.c)
  • Re: Automatically generate variables
    ... Must be C by your definition since crapit might possibly be a header that makes it C. ... I knew it was *the* windows windows.h header because the ... if the question was "how much of the program is standard C?" ... that it's just as non-standard as my version. ...
    (comp.lang.c)
  • Re: Non-English Validation Expression for email address?
    ... The Internet Engineering Task Force has published three crucial documents for the standardisation of email address headers that include symbols outside the ASCII character set. ... This means that soon you'll be able to use Chinese characters, French accents, and German umlauts in email addresses as well as just in the body of the message. ... They say there would need to be an "upgrade mania" if the Unicode standard UTF-8 is to replace the American Standard Code for Information Interchange currently used as the general email language. ... A new header field will be added as a sort of "emergency parachute" to ensure that UTF-8 emails have a soft landing if they are thrown out before reaching the recipient by systems that have not been upgraded. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Debugging memory leaks
    ... implementing this that the C standard does not address. ... I made one header file that, when included, replaces ... allocated memory in a list. ... frees, allocations of zero size, or missing calls to free. ...
    (comp.lang.c)
  • Re: Replacing COMMON Components by customized ones
    ... It will be either CE project specific (if modifying a CE project cesysgen) ... or for every CE projects whatever the platform is (if modifying the IABASE ... intll standard feature when included in the image. ... > My be remark it then rebuild the BSP. ...
    (microsoft.public.windowsce.platbuilder)