Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Can wchar_t be safely past to a dll?


This question is answered.


Permlink Replies: 1 - Last Post: Nov 2, 2016 10:55 AM Last Post By: Remy Lebeau (Te...
Larry Johnson

Posts: 86
Registered: 6/7/14
Can wchar_t be safely past to a dll?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 2, 2016 9:06 AM
I am using XE4 32bit VCL for windows application. The message below appears at the top of a dll and does not reference the wide string type wchar_t. Can the wchar_t be used the same as the char type described below?

// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char *" or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Can wchar_t be safely past to a dll?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 2, 2016 10:55 AM   in response to: Larry Johnson in response to: Larry Johnson
Larry wrote:

I am using XE4 32bit VCL for windows application. The message
below appears at the top of a dll and does not reference the
wide string type wchar_t. Can the wchar_t be used the same
as the char type described below?

wchar_t itself is just a basic character type defined by the C/C++ language
standards. It is perfectly safe to pass it around as-is, as well as pointers
to wchar_t-based character strings. The comment about "To avoid using BORLNDMM.DLL,
pass string information using "char *" or ShortString parameters" should
be expanded to include "wchar_t*" as well.

The warning refers to passing around Delphi-style strings (AnsiString and
UnicodeString) and other types that rely on the Delphi memory manager and
thus are not safe for interop across the DLL boundary.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02