Click here to Skip to main content
15,891,828 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: fopen problem in ATL Pin
Jörgen Sigvardsson11-Sep-06 2:25
Jörgen Sigvardsson11-Sep-06 2:25 
GeneralRe: fopen problem in ATL Pin
Stephen Hewitt11-Sep-06 14:46
Stephen Hewitt11-Sep-06 14:46 
GeneralRe: fopen problem in ATL Pin
Jörgen Sigvardsson11-Sep-06 15:06
Jörgen Sigvardsson11-Sep-06 15:06 
GeneralRe: fopen problem in ATL Pin
_tasleem12-Sep-06 3:02
_tasleem12-Sep-06 3:02 
AnswerRe: fopen problem in ATL Pin
Stuart Dootson11-Sep-06 8:30
professionalStuart Dootson11-Sep-06 8:30 
GeneralRe: fopen problem in ATL Pin
_tasleem12-Sep-06 23:58
_tasleem12-Sep-06 23:58 
QuestionAllow placement on my control in design-time Pin
Tilir7-Sep-06 20:08
Tilir7-Sep-06 20:08 
QuestionProblem: WTL::CString exchange between pure WTL DLLs (note: no MFC intermixing) Pin
x-b7-Sep-06 0:41
x-b7-Sep-06 0:41 
Hi all, I'm confused and liked to know your opinion.

In short:
I think there is a general WTL::CString design problem if a CString is
passed by reference between DLLs to retrieve data.

Example, calling the following DLL-provided method to this is not safe:
int GetName(CString& o_strName);

In long:
Referring to ATLMISC.H, an empty CString will point to a global
variable named rgInitData. rgInitData acts as a global placeholder to be pointed to for any initially empty strings.

<br />
//global dummy instance where an CString will point to if it is empty<br />
_declspec(selectany) int rgInitData[] = { -1, 0, 0, 0 };<br />
<br />
//global pointer, is used for comparsion to see if a CString is empty or points to real data.<br />
_declspec(selectany) CStringData* _atltmpDataNil = (CStringData*) &rgInitData;<br />


Since any file that uses WTL::CString #inlcudes the code above, it will get an rgInitData in for each obj file, to avoid linker problems the declspec is used. Thats ok so far.

But problems arise in case of DLL projects, as each DLL will get its own rgInitData instance with the corresping atltmpDataNil pointer.

The problem is: create an empty CString in DLL-A, the CString will point to its rgInitData-A object to indicate it is empty.
Now handing this CString object over to DLL-B, then the CString internal implementation uses the address of rgInitData-B to determine if its an empty string or not.
As the match will fail, the DLL-B side implementation assumes there is data to be freed, resulting in attempting to free rgInitData-A (which is a global variable on the stack).

Do you agree? Do you know a workaround?

Regards
Xavi

Please note, that here no Debug/Realease or MFC, non-MFC issues apply.
AnswerRe: Problem: WTL::CString exchange between pure WTL DLLs (note: no MFC intermixing) Pin
Michael Dunn9-Sep-06 17:31
sitebuilderMichael Dunn9-Sep-06 17:31 
GeneralRe: Problem: WTL::CString exchange between pure WTL DLLs (note: no MFC intermixing) Pin
x-b10-Sep-06 22:34
x-b10-Sep-06 22:34 
GeneralRe: Problem: WTL::CString exchange between pure WTL DLLs (note: no MFC intermixing) Pin
Michael Dunn11-Sep-06 7:28
sitebuilderMichael Dunn11-Sep-06 7:28 
QuestionSTL List - object creation / destruction wierdness Pin
neilsolent6-Sep-06 21:39
neilsolent6-Sep-06 21:39 
AnswerRe: STL List - object creation / destruction wierdness Pin
Stuart Dootson7-Sep-06 9:05
professionalStuart Dootson7-Sep-06 9:05 
AnswerRe: STL List - object creation / destruction wierdness Pin
Zac Howland7-Sep-06 9:23
Zac Howland7-Sep-06 9:23 
GeneralRe: STL List - object creation / destruction wierdness Pin
neilsolent7-Sep-06 9:49
neilsolent7-Sep-06 9:49 
GeneralRe: STL List - object creation / destruction wierdness Pin
Zac Howland7-Sep-06 11:03
Zac Howland7-Sep-06 11:03 
GeneralRe: STL List - object creation / destruction wierdness Pin
Stuart Dootson8-Sep-06 3:01
professionalStuart Dootson8-Sep-06 3:01 
GeneralRe: STL List - object creation / destruction wierdness Pin
Zac Howland8-Sep-06 3:57
Zac Howland8-Sep-06 3:57 
GeneralRe: STL List - object creation / destruction wierdness Pin
Stuart Dootson8-Sep-06 5:48
professionalStuart Dootson8-Sep-06 5:48 
GeneralRe: STL List - object creation / destruction wierdness Pin
Zac Howland8-Sep-06 6:06
Zac Howland8-Sep-06 6:06 
QuestionRelease build seg faults at vector push_back Pin
rana745-Sep-06 6:38
rana745-Sep-06 6:38 
AnswerRe: Release build seg faults at vector push_back Pin
led mike5-Sep-06 6:55
led mike5-Sep-06 6:55 
AnswerRe: Release build seg faults at vector push_back Pin
valikac5-Sep-06 8:12
valikac5-Sep-06 8:12 
AnswerRe: Release build seg faults at vector push_back Pin
Zac Howland7-Sep-06 9:27
Zac Howland7-Sep-06 9:27 
QuestionIs it possible to convert Visual C++ program with GUI into COM DLL or ActiveX ? Pin
peysock5-Sep-06 6:35
peysock5-Sep-06 6:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.