2009-08-12 117 views
1

我有Visual Studio 2008中的#define _AFX_NO_DEBUG_CRT導致編譯錯誤,流

中的#include之前我加入我的stdafx.h一個_AFX_NO_DEBUG_CRT下MFC C++編譯器項目,以避免所有調試新刪除MFC提供的(我希望提供我自己的更好的跨平臺兼容性)。

但是當我這樣做,我得到錯誤的數據流,如下列:

>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2059: syntax error : '__asm' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ')' before '{' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ')' before '{' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ')' before '{' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ';' before '{' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : warning C4091: '' : ignored on left of 'int' when no variable is declared 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ';' before 'constant' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ';' before '}' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2143: syntax error : missing ';' before ',' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2059: syntax error : ')' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2059: syntax error : ')' 
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxtls_.h(62) : error C2059: syntax error : ')' 
1 

我「認爲」它可能有一些做與__asm INT 3電話,但我不能肯定。有沒有人有過這個問題?如果是這樣,你是如何解決它的?我堅持MFC的內存跟蹤?我真的希望不要因爲它會讓我的圖書館少了很多跨平臺:(

任何幫助將非常感激!

回答

2

我想出了一種方法,它涉及使用/ FORCE:MULTIPLE命令行強制它使用我的而不是MFC。這一切似乎都很好。我現在甚至可以跟蹤由不屬於我的功能執行的「malloc」和「new」:)

如果任何人有任何更好的解決方案,那麼請張貼他們,但現在這似乎解決了我的問題:)

+0

仍然不回答爲什麼你的「跨平臺」庫鏈接MFC的問題? – 2009-08-12 19:38:36

+0

MFC應用程序正在鏈接我的跨平臺庫... – Goz 2009-08-12 20:37:40

+0

您是否介意解釋如何解決編譯問題? 我得到和你一樣的編譯錯誤 - 你是否刪除了你的#define _AFX_NO_DEBUG_CRT? – Alan 2009-10-14 15:20:25

0

嘗試把中的#define項目編譯選項,而不是在stdafx的頂部。小時。

你怎麼能指望,如果你使用MFC?避免新建立一個跨平臺的庫,並刪除重載不會有所作爲。

而且,你永遠不會寫分配跟蹤器像MFC提供的那樣可靠和完整。YAGNI,專注於開發你的實體l應用程序。

+0

我的庫是跨平臺而不是MFC部分。 – Goz 2009-08-12 12:23:14

+0

另外值得注意的是,把它放入項目定義也不起作用。 – Goz 2009-08-12 12:50:09

+0

如果你的庫是跨平臺的,爲什麼它需要一個MFC#define? – 2009-08-12 19:37:12

2

我在過去曾試圖搞亂_AFX_NO_DAO_SUPPORT宏,它所做的一切都是導致無休止的崩潰。我終於碰到這個文章就來了:

PRB: Problems Occur When Defining _AFX_NO_XXX

它沒有具體列出您在嘗試使用,但它可能仍然適用。

+0

酷絕對值得知道,但定義即時嘗試使用似乎並不影響VTABLES。它似乎只是爲了一堆服務功能,而不是在類中使用。 – Goz 2009-08-12 20:39:51

相關問題