導航:首頁 > 源碼編譯 > 預編譯error指令

預編譯error指令

發布時間:2025-01-07 03:02:01

① 關於C語言在編譯時常出現的錯誤有哪些

1、fatal error C1010: unexpected end of file while looking for precompiled header directive。

尋找預編譯頭文件路徑時遇到了不該遇到的文件尾。(一般是沒有#include "stdafx.h")

2、fatal error C1083: Cannot open include file: 'R…….h': No such file or directory

不能打開包含文件「R…….h」:沒有這樣的文件或目錄。

3、error C2011: 'C……': 'class' type redefinition

類「C……」重定義。

4、error C2018: unknown character '0xa3'

不認識的字元'0xa3'。(一般是漢字或中文標點符號)

5、error C2057: expected constant expression

希望是常量表達式。(一般出現在switch語句的case分支中)

6、error C2065: 'IDD_MYDIALOG' : undeclared identifier

「IDD_MYDIALOG」:未聲明過的標識符。

7、error C2082: redefinition of formal parameter 'bReset'

函數參數「bReset」在函數體中重定義。

8、error C2143: syntax error: missing ':' before '{'

句法錯誤:「{」前缺少「;」。

9、error C2146: syntax error : missing ';' before identifier 'dc'

句法錯誤:在「dc」前丟了「;」。

10、error C2196: case value '69' already used

值69已經用過。(一般出現在switch語句的case分支中)

11、error C2509: 'OnTimer' : member function not declared in 'CHelloView'

成員函數「OnTimer」沒有在「CHelloView」中聲明。

12、error C2511: 'reset': overloaded member function 'void (int)' not found in 'B'

重載的函數「void reset(int)」在類「B」中找不到。

13、error C2555: 'B::f1': overriding virtual function differs from 'A::f1' only by return type or calling convention

類B對類A中同名函數f1的重載僅根據返回值或調用約定上的區別。

14、error C2660: 'SetTimer' : function does not take 2 parameters

「SetTimer」函數不傳遞2個參數。

15、warning C4035: 'f……': no return value

「f……」的return語句沒有返回值。

16、warning C4553: '= =' : operator has no effect; did you intend '='?

沒有效果的運算符「= =」;是否改為「=」?

17、warning C4700: local variable 'bReset' used without having been initialized

局部變數「bReset」沒有初始化就使用。

18、error C4716: 'CMyApp::InitInstance' : must return a value

「CMyApp::InitInstance」函數必須返回一個值。

19、LINK : fatal error LNK1168: cannot open Debug/P1.exe for writing

連接錯誤:不能打開P1.exe文件,以改寫內容。(一般是P1.Exe還在運行,未關閉)

20、error LNK2001: unresolved external symbol "public: virtual _ _thiscall C……::~C……(void)"

連接時發現沒有實現的外部符號(變數、函數等)。

function call missing argument list 調用函數的時候沒有給參數。

member function definition looks like a ctor, but name does not match enclosing class 成員函數聲明了但沒有使用

unexpected end of file while looking for precompiled header directive 在尋找預編譯頭文件時文件意外結束,編譯不正常終止可能造成這種情況

② #error "在包含此文件之前包含「stdafx.h」以生成 PCH 文件"

應該是要包含預編譯頭文件「stdafx.h」,在代碼的前面#include"stdafx.h".

或者如果是使用VC6.0在工程->設置->c\c++選項卡->(分類)預編譯的頭文件
->不使用預編譯頭文件->確定。

③ 關於C語言預處理命令

第一句有問題。
比如
#ifndef WIN32
#endif printf("OK\n");
在這里,這個printf就不會被執行。也就是說, 一行中, 只能有一條預處理指令,
當編譯的預處理階段, 編譯器識別了一條完整的預處理指令後,後面的所有東西他都不要了。
對於第二句,在函數里,我們是可以使用預處理指令的。
比如
void fun(void)
{
#ifdef WIN32
... // 對於windows系統環境的操作
#else
... // 對於windows以外的系統環境的操作
#endif /* WIN32 */
...
}

樓上的同學, 你是在哪兒本書上看的? 介紹一下唄

④ fatal error C1010: 在查找預編譯頭時遇到意外的文件結尾...

fatal error C1010: 在查找預編譯頭時遇到意外的文件結尾是因為沒選擇「不使用預編譯頭」。解決步驟如下:

1、首先第一步就是要進行使用預編譯頭文件「stdafx.h」,這時候注意的是加入第三方c/cpp文件沒有#include "stdafx.h",就會報此錯誤。


閱讀全文

與預編譯error指令相關的資料

熱點內容
松餅pdf 瀏覽:667
萌新如何獲得命令 瀏覽:138
java設計模式及代碼 瀏覽:7
命令恢復資料庫 瀏覽:192
linuxoracle11gr2 瀏覽:972
攜程APP簽到在哪裡 瀏覽:389
dwg解壓方法 瀏覽:422
雲伺服器數據溝通 瀏覽:849
android地圖定位源碼 瀏覽:632
鴻蒙系統如何解除app安裝限制 瀏覽:497
阿里雲伺服器應用鏡像選哪個 瀏覽:343
win7策略更新命令 瀏覽:299
android源碼分析之設計模式 瀏覽:294
qq郵箱上的文件怎麼解壓在電腦上 瀏覽:504
業余學python是如何掙錢的 瀏覽:416
方舟伺服器連接超時顯示什麼 瀏覽:226
php繪制emoji 瀏覽:35
安卓桌面工具怎麼刪除 瀏覽:54
外六角螺絲套頭演算法 瀏覽:838
程序員特殊招數是什麼意思 瀏覽:352