VC++ warning C4290

來源:互聯網
上載者:User

VC++warning C4290

Mingyuan 2009/5/9

聲明了兩個函數:

int DivideFun(int a,int b) throw(string,int);

double SqrtFun(double a) throw(double);

編譯時間出現警告如下:

warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

原因:

http://msdn.microsoft.com/en-us/library/sa28fef8(vs.80).aspx

Error Message

C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

A function is declared using exception specification, which Visual C++ accepts but does not implement. Code with exception specifications that are ignored during compilation may need to be recompiled and linked to be reused in future versions supporting exception specifications.

http://msdn.microsoft.com/zh-cn/library/sa28fef8(vs.80).aspx

錯誤訊息

忽略 C++ 異常規範,但指示函數不是 __declspec(nothrow)

使用異常規範聲明函數,Visual C++ 接受但並不實現此規範。包含在編譯期間被忽略的異常規範的代碼可能需要重新編譯和連結,以便在支援異常規範的未來版本中重用。

有關更多資訊,請參見 Exception Specifications。

http://msdn.microsoft.com/zh-tw/library/sa28fef8(vs.80).aspx

���息

略� C++ 例外���格,除非�函式�示�非 __declspec(nothrow)

函式是用 Visual C++ 接受但未�作的例外���格宣告的。如果程式�的例外���格在���程中被忽略了,那��程式�可能必�重新��及��,以便在新版的支援例外���格中重�利用。

解決方案:

在函式宣告前加:#pragma warning (disable:4290)

結果如下:

#pragma warning (disable:4290)

int DivideFun(int a,int b) throw(string,int);

double SqrtFun(double a) throw(double);

此方案只是保證編譯器不再彈出警告,但是不能保證編譯器接受異常規範(例外���格宣告、exception specification)。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.