簡體   English   中英

C ++中的奇怪編譯器錯誤(VC編譯器)

[英]Odd Compiler Error in C++ (VC compiler)

對於此代碼,

#include <math.h>
int main()
{
    float x = 1.5f;
    float y = 0.0f;
/*line6*/   y = pow(x, 6) * 235809835.41 - pow(x, 5) * 2110439254.2 + pow(x, 4) *7869448124.8 - pow(x, 3) * 15648965509 + pow(x, 2) * 17503313074 - (x)* 10440563329 + 2594694745‏; // error
/*line7*/   y = pow(x, 6) * 235809835.41 - pow(x, 5) * 2110439254.2 + pow(x, 4) *7869448124.8 - pow(x, 3) * 15648965509 + pow(x, 2) * 17503313074 - (x)* 10440563329 + 2594694745;
    return 0;
}

我收到以下錯誤日志 -

maincpp.cpp(6) : warning C4244 : '=' : conversion from 'double' to 'float', possible loss of data
maincpp.cpp(6) : error C2146 : syntax error : missing ';' before identifier '‏'
maincpp.cpp(6) : error C2065 : '‏' : undeclared identifier

第6行無法編譯。 我發現最令人驚訝的是第7行編譯,即使它與第6行相同。因此,如果我注釋第6行並保留第7行,那么程序將成功編譯。

我在Windows 8 64位上,這個程序是在Visual Studio 2013中用Win 32控制台應用程序編寫的。

在生產代碼中,我將使用f終止所有浮點文字。 但無論如何,如果沒有它,我不指望編譯錯誤。

方程式在Excel中生成。

看起來你在分號前的第6行有一個偏離的從右到左的標記

... 2594694745<U+200F>; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM