Joe_Banks_217
asked on
AFX_MANAGE_STATE(AfxGetStaticModuleState()) needs to be taken out
Hi all,
I got a question that has been bothering me for a long time now. I have 4 builds....debug, unicode debug, release, and unicode release. The macro
"AFX_MANAGE_STATE(AfxGetSt aticModule State())" works fine for all the builds except
unicode release. In order for unicode release to work, I need to take that macro out. Has anyone ever seen this before, or is it just indiginous to my application???
500 pts.
thanks
I got a question that has been bothering me for a long time now. I have 4 builds....debug, unicode debug, release, and unicode release. The macro
"AFX_MANAGE_STATE(AfxGetSt
unicode release. In order for unicode release to work, I need to take that macro out. Has anyone ever seen this before, or is it just indiginous to my application???
500 pts.
thanks
ASKER
no i don't think so andy. what do you think could be causing this?
From a dll generated by the MFC wizards.
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetSta ticModuleS tate());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
Removing that line *could* be very dangerous.
Your problem - I've not encountered it. Are you using any other special flags for the unicode release that you don't for the other builds? (Check your project settings - specifically the 'release' and the 'unicode release' versions)
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetSta
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
Removing that line *could* be very dangerous.
Your problem - I've not encountered it. Are you using any other special flags for the unicode release that you don't for the other builds? (Check your project settings - specifically the 'release' and the 'unicode release' versions)
ASKER
Andy, what do you mean by special flags? Like preprocessor directives?
yes.
ASKER
Andy, could the problem be because the project has both atl and mfc in it?
? - but why should it work in debug and non-unicode versions?
If the settings are the same for debug and release then I have no other ideas at present.
If the settings are the same for debug and release then I have no other ideas at present.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Andy, what would shared or static libraries have to do with it?
ASKER
I found this article.
http://www.codeguru.com/cpp/com-tech/atl/atl/article.php/c55/
I kind of thought that it was applicable because it mentions that AfxGetApp() would not work right in such an application. In my application, two main reasons why the unicode release crashes
are 1) AfxGetApp()->GetProfileStr ing either crashes the program or fails and 2) the interface functions we call crash. However, I still don't really understand the problem, or for that matter how to solve it.
http://www.codeguru.com/cpp/com-tech/atl/atl/article.php/c55/
I kind of thought that it was applicable because it mentions that AfxGetApp() would not work right in such an application. In my application, two main reasons why the unicode release crashes
are 1) AfxGetApp()->GetProfileStr
static/shared linkage.
// If this DLL is dynamically linked against the MFC <<------------------ It seems to say only required for shared linkage
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
2) the interface functions we call crash.
I think this is due to you removing this line AFX_MANAGE_STATE(AfxGetSta ticModuleS tate())
// If this DLL is dynamically linked against the MFC <<------------------ It seems to say only required for shared linkage
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
2) the interface functions we call crash.
I think this is due to you removing this line AFX_MANAGE_STATE(AfxGetSta
Are you using any other special flags for the unicode release that you don't for the other builds?