Skip to main content
GameDev.net gamedev.net
🔒 Locked

ATLComTime.h fighting with /clr:pure?

Started by IADaveMark Aug 11, 2010 at 2:21 PM 5 replies 3.7k views
Original Post
IADaveMark
IADaveMark
OK... simple Windows Forms app. However, simply by including , I get a string of C3641 errors:
Quote:
Error 1 error C3641: 'InterlockedExchangePointer' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
Error 2 error C3641: 'ATL::_AtlGetConversionACP' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
Error 3 error C3641: 'AtlA2WHelper' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
Error 7 error C3641: 'AtlDevModeW2A' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe
Error 8 error C2440: 'default argument' : cannot convert from 'int (__cdecl *)(int,const char *,int,const char *,const char *,...)' to 'ATL::CTrace::fnCrtDbgReport_t'C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atltrace.h 146
Error 9 fatal error C1903: unable to recover from previous error(s); stopping compilation C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\atltrace.h 146

Of course, if I set the properties of the project to /clr (without pure or safe), it compiles just fine but blows up at run time error right at the outset with an assert citing something amiss in "debugheap.c"...
Quote:
Expression: _CrtIsValidHeapPointer(pUserData)

The code in dbgheap.c that the assert is on is:

        /*         * If this ASSERT fails, a bad pointer has been passed in. It may be         * totally bogus, or it may have been allocated from another heap.         * The pointer MUST come from the 'local' heap.         */        _ASSERTE(_CrtIsValidHeapPointer(pUserData));

(Kudos to MS for using "totally bogus" in a comment.)

The call stack at this point doesn't seem to help. Again, this is at run-time before the code even enters the main{} function. This error goes away once I comment out the include of the ATLComTime again. That is, the rest of the code doesn't mind having /clr in effect (without 'pure').

My question is... which of these two should I be trying to fix and how? Is it not permissible to use ATLComTime (and the COleDateTime functions it holds) with Windows Forms? Alternately, why can't I run code in /clr mode without ATLComTime throwing up this "totally bogus" pointer?

Thoughts?
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit<
IADaveMark
IADaveMark
Follow up. As per this very brief post, the problem comes when anything ATL or MFC is used in a WinForm application. The workaround is allegedly to change the settings for entry points from "/ENTRY:main" to "/NOENTRY" or something like that. When I do that, however, I get this:
Quote:
Error 42 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup MSVCRTD.lib


Anyone? Anyone?
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit<
Washu
Washu
Erm, why are you trying to mix ATL and /clr:pure code?

That's a recipe for disaster.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
IADaveMark
IADaveMark
I'd rather not. The whole thing started when I needed a date/time type for my data. I went back to my old C++ standby of COleDateTime which is in .

Is there a Date/Time class/type that I can use in a normal .NET WinForm environment?
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit<
Washu
Washu
Uh. Yeah.

System.DateTime.

Pre-emptive strike:
System.TimeSpan.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
IADaveMark
IADaveMark
Beer for you. Collect at GDC Austin or GDC San Fran.
Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit<
Washu
Washu
Quote:
Original post by InnocuousFox
Beer for you. Collect at GDC Austin or GDC San Fran.


GDC SF it is.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.