locked
Compile error on MFC/CLR app RRS feed

  • Question

  • Hi, I'm new to Visual c++ and am currently making one of my first programs. I'm trying to use the CCriticalSection and CSingleLock classes in this program, and to do so, I know I need to include <afxmt.h>.

    Well, when I try to compile my program for debug, I get all kinds of errors like this:  I duno why I get them, but if some1 could please help me fix the problem, I would greatly appreciate it.

    ------ Build started: Project: Dales Name Genz0r Beta, Configuration: Debug Win32 ------

    Compiling...

    stdafx.cpp

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afxv_w32.h(194) : error C3641: 'DrawState' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afxv_w32.h(208) : error C3641: 'DrawStatusText' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

    C:\Program Files\Microsoft Platform SDK\Include\winbase.h(1849) : error C3641: 'FreeResource' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afxv_w32.h(222) : error C3641: 'UnlockResource' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(642) : warning C4561: '__fastcall' incompatible with the '/clr' option: converting to '__stdcall'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1171) : error C2143: syntax error : missing '}' before 'generic'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1171) : error C2059: syntax error : 'generic'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1178) : error C2143: syntax error : missing ';' before '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1178) : error C2238: unexpected token(s) preceding ';'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1181) : error C2062: type 'int' unexpected

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1189) : error C2059: syntax error : 'public'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1190) : error C2588: '::~CArchiveException' : illegal global destructor

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1190) : error C2575: 'CArchiveException' : only member functions and bases can be virtual

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1190) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1192) : error C2270: 'Dump' : modifiers not allowed on nonmember functions

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1195) : error C2575: 'GetErrorMessage' : only member functions and bases can be virtual

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1196) : error C2059: syntax error : '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1196) : error C2143: syntax error : missing ';' before '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1196) : error C2059: syntax error : '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1205) : error C2143: syntax error : missing '}' before 'generic'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1205) : error C2059: syntax error : 'generic'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1219) : error C2143: syntax error : missing ';' before '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1219) : error C2238: unexpected token(s) preceding ';'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1222) : error C2062: type 'int' unexpected

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1226) : error C2086: 'int m_cause' : redefinition

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1185) : see declaration of 'm_cause'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1228) : error C2086: 'CString m_strFileName' : redefinition

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1186) : see declaration of 'm_strFileName'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1240) : error C2059: syntax error : 'public'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1241) : error C2588: '::~CFileException' : illegal global destructor

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1241) : error C2575: 'CFileException' : only member functions and bases can be virtual

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1241) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1243) : error C2270: 'Dump' : modifiers not allowed on nonmember functions

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1246) : error C2575: 'GetErrorMessage' : only member functions and bases can be virtual

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1246) : error C2572: 'GetErrorMessage' : redefinition of default parameter : parameter 3

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1194) : see declaration of 'GetErrorMessage'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1247) : error C2059: syntax error : '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1247) : error C2143: syntax error : missing ';' before '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1247) : error C2059: syntax error : '}'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1317) : error C2061: syntax error : identifier 'CFileException'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afx.h(1398) : error C2061: syntax error : identifier 'CFileException'

    C:\Program Files\Microsoft Platform SDK\Include\mfc\afxtls_.h(122) : error C3641: 'CThreadSlotData::operator new' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

    Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\Dales Name Genz0r Beta\Dales Name Genz0r Beta\Debug\BuildLog.htm"

    Dales Name Genz0r Beta - 38 error(s), 1 warning(s)

    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Tuesday, August 15, 2006 8:37 PM

Answers

  • The Express Edition does not include ATL or MFC - if you need these libraries then you need to upgrade to at least the Standard Edition. Note: you should find that the .NET Framework, which the Express Edition does include, contains all the functionality that you need.

    For example take a look at contents of the System::Threading namespace.

    Tuesday, August 15, 2006 9:40 PM

All replies

  • You probably have the wrong preprocessor settings.  Try creating an MFC app from scratch using the MFC Project Wizard, turn on CLR, and then compile.  If it succeeds, then you have a build that you can model from.
    Tuesday, August 15, 2006 8:40 PM
  • From the error messages that you are getting it looks like you are using the MFC that shipped as part of the Platform SDK - this is an old version of MFC and dates from the days when the only way to get a 64-bit compiler, headers, and libraries was with the Platform SDK. This version of MFC will not work with /clr. You need to get the version of MFC that shipped with all versions Visual C++ 2005 except the Express Edition.
    Tuesday, August 15, 2006 8:51 PM
  • thanks for the input. I have the express Edition though, so where can i get that version of MFC??
    Tuesday, August 15, 2006 9:17 PM
  • The Express Edition does not include ATL or MFC - if you need these libraries then you need to upgrade to at least the Standard Edition. Note: you should find that the .NET Framework, which the Express Edition does include, contains all the functionality that you need.

    For example take a look at contents of the System::Threading namespace.

    Tuesday, August 15, 2006 9:40 PM
  • check out msdn

    InitializeCriticalSection
    DeleteCriticalSection

    not familiar with product features, nonetheless, windows api is superior i/o

    Kuphryn

    Tuesday, August 15, 2006 10:15 PM