简体   繁体   English

C ++中的奇怪编译器错误(VC编译器)

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

For this code, 对于此代码,

#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;
}

I get the following error log - 我收到以下错误日志 -

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

Line 6 fails to compile. 第6行无法编译。 What I find most astonishing is that line 7 compiles even though it is identical to line 6. So, if I comment out line 6 and retain line 7, then the program compiles successfully. 我发现最令人惊讶的是第7行编译,即使它与第6行相同。因此,如果我注释第6行并保留第7行,那么程序将成功编译。

I am on Windows 8 64 bit, and this program was written in Visual Studio 2013 as a Win 32 Console Application. 我在Windows 8 64位上,这个程序是在Visual Studio 2013中用Win 32控制台应用程序编写的。

In production code, I would terminate all float literals with f. 在生产代码中,我将使用f终止所有浮点文字。 But in any case, I don't expect a compiler error without it. 但无论如何,如果没有它,我不指望编译错误。

The equation was generated in Excel. 方程式在Excel中生成。

看起来你在分号前的第6行有一个偏离的从右到左的标记

... 2594694745<U+200F>; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM