Click here to Skip to main content
15,915,093 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How could I get the parent of an embedded control generically ? Pin
Nibu babu thomas17-Aug-08 19:08
Nibu babu thomas17-Aug-08 19:08 
GeneralRe: How could I get the parent of an embedded control generically ? Pin
Naveen17-Aug-08 19:13
Naveen17-Aug-08 19:13 
GeneralRe: How could I get the parent of an embedded control generically ? Pin
Nibu babu thomas17-Aug-08 19:16
Nibu babu thomas17-Aug-08 19:16 
GeneralRe: How could I get the parent of an embedded control generically ? Pin
SherTeks17-Aug-08 19:28
SherTeks17-Aug-08 19:28 
GeneralRe: How could I get the parent of an embedded control generically ? Pin
Nibu babu thomas17-Aug-08 19:59
Nibu babu thomas17-Aug-08 19:59 
GeneralRe: How could I get the parent of an embedded control generically ? Pin
SherTeks17-Aug-08 21:59
SherTeks17-Aug-08 21:59 
AnswerRe: How could I get the parent of an embedded control generically ? Pin
Naveen17-Aug-08 19:11
Naveen17-Aug-08 19:11 
QuestionWeird stack corruption problem Pin
jozsurf17-Aug-08 18:11
jozsurf17-Aug-08 18:11 
...at least it appears to be a problem with stack corruption.

Here's the problem. I'm attempted to use std::string in some existing code for an enhancement I'm doing and was getting in all sorts of trouble (mainly centring around the fact that my this pointer gets trampled on). At first I thought there was something in ATL which stopped it from playing nicely with STL, but a nice person on this forum assured me that this is not the case. After a bit of shadow chasing, I think I've narrowed down the cause of the problem: the stack gets corrupted if I attempt to use a std::string (since the use of a std::string from the ATL code would presumably require a casting-type operation) in a call level deeper than two functions. That last bit was probably unintelligible (since I made that phrase up) so I'll attempt to illustrate my point with some code:

STDMETHODIMP SomeClass::SomeFunction () 
{ 
    std::string tmp = "This is a std::string"; 
    AnotherFunction(); 
}
 
void SomeClass::AnotherFunction () 
{ 
    std::string tmp = "This is a std::string"; 
} 

So if I were to drop a break point at the two std::string declarations, we have no problems when it runs through the first one (in SomeFunction) but as soon as it passes the second (in AnotherFunction), the this pointer gets corrupted ... almost as if the stack pointer got lost whilst trying to deal with the std::string.

I should add that I'm doing this on VC6.0.

Anyone ever seen this before? Anyway to get around it? It sucks having to replicate my code rather than being able to write it in a function and simply call that function everywhere I need to...

cheers!
AnswerRe: Weird stack corruption problem Pin
Naveen17-Aug-08 18:22
Naveen17-Aug-08 18:22 
AnswerRe: Weird stack corruption problem Pin
Stephen Hewitt17-Aug-08 18:24
Stephen Hewitt17-Aug-08 18:24 
GeneralRe: Weird stack corruption problem Pin
jozsurf17-Aug-08 18:33
jozsurf17-Aug-08 18:33 
GeneralRe: Weird stack corruption problem Pin
Stephen Hewitt17-Aug-08 18:36
Stephen Hewitt17-Aug-08 18:36 
GeneralRe: Weird stack corruption problem Pin
jozsurf17-Aug-08 19:45
jozsurf17-Aug-08 19:45 
GeneralRe: Weird stack corruption problem Pin
Stephen Hewitt17-Aug-08 19:57
Stephen Hewitt17-Aug-08 19:57 
GeneralRe: Weird stack corruption problem Pin
jozsurf17-Aug-08 20:23
jozsurf17-Aug-08 20:23 
GeneralRe: Weird stack corruption problem Pin
Nibu babu thomas17-Aug-08 18:52
Nibu babu thomas17-Aug-08 18:52 
GeneralRe: Weird stack corruption problem Pin
Stephen Hewitt17-Aug-08 19:49
Stephen Hewitt17-Aug-08 19:49 
GeneralRe: Weird stack corruption problem Pin
jozsurf17-Aug-08 19:55
jozsurf17-Aug-08 19:55 
QuestionDo I need call CString::Empty? Pin
fantasy121517-Aug-08 17:27
fantasy121517-Aug-08 17:27 
AnswerRe: Do I need call CString::Empty? Pin
Naveen17-Aug-08 17:46
Naveen17-Aug-08 17:46 
GeneralRe: Do I need call CString::Empty? Pin
fantasy121517-Aug-08 17:54
fantasy121517-Aug-08 17:54 
GeneralRe: Do I need call CString::Empty? Pin
Naveen17-Aug-08 18:01
Naveen17-Aug-08 18:01 
AnswerRe: Do I need call CString::Empty? Pin
ThatsAlok19-Aug-08 20:34
ThatsAlok19-Aug-08 20:34 
QuestionRe: Do I need call CString::Empty? Pin
nul2629-Sep-10 22:34
nul2629-Sep-10 22:34 
AnswerRe: Do I need call CString::Empty? Pin
ThatsAlok30-Sep-10 2:49
ThatsAlok30-Sep-10 2:49 

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.