VC error C4430 和 C2533 錯誤

來源:互聯網
上載者:User

昨晚調試個程式,被這破問題搞了大半夜。

因為我在 .h 和 .cpp 檔案中使用了 static 的類全域變數,需要在類構造前對這些變數進行初始化

Status CXGdiplus::m_uGdiplusStatus = Gdiplus::GdiplusNotInitialized;<br />ULONG_PTR CXGdiplus::m_ulGdiplusToken = 0;

 

開始的時候 Visual Studio 編譯老提示我:

錯誤 1 error C2143: 語法錯誤 : 缺少“;”(在“CXGdiplus::m_uGdiplusStatus”的前面) d:/cppcsprjs/gdiplusdemo/xgdiplus.cpp 32 GdiplusDemo

 

錯誤 4 error C4430: 缺少類型說明符 - 假定為 int。注意: C++ 不支援預設 int d:/cppcsprjs/gdiplusdemo/xgdiplus.cpp 32 GdiplusDemo

 

於是一點點排查,最後幾乎把所有的代碼都快注釋掉了,這次 Visual Studio 提示我:

錯誤 1 error C2533: “CXGdiplus::{ctor}”: 建構函式不能有傳回型別 d:/cppcsprjs/gdiplusdemo/xgdiplus.cpp 41 GdiplusDemo

 

於是搜尋了一下,終於發現原來是我用 UE 敲代碼的時候,那個 .h 檔案 class 聲明結尾的 "}" 之後還有個分號 ";" 被我不小心漏掉了。

折騰了這大半夜竟然是這低級錯誤,鬱悶死。

所以特意把這個貼出來,警示自己不要再犯了 ⊙﹏⊙b汗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.