简体   繁体   English

奇怪的编译器行为(C ++)

[英]Weird Compiler behavior (C++)

I'm trying to add GA library (GALib) to my error-free program, when I add it, the compiler returns strange errors and repeat them so many times... For an example, "syntax error: missing '{' before '<' " is returned for the first line of the following template code: 我正在尝试将GA库(GALib)添加到我的无错程序中,当我将其添加时,编译器会返回奇怪的错误并重复多次。例如,“语法错误:之前缺少'{'以下模板代码的第一行返回'<'“:

template<class _Ty>
_Check_return_ inline _Ty _Pow_int(_Ty _Xx, int _Yx) _NOEXCEPT
{
unsigned int _Nx;
if (_Yx >= 0)
    _Nx = static_cast<unsigned int>(_Yx);
else
    _Nx = static_cast<unsigned int>(-_Yx);

for (_Ty _Zx = static_cast<_Ty>(1); ; _Xx *= _Xx)
    {
    if ((_Nx & 1) != 0)
        _Zx *= _Xx;
    if ((_Nx >>= 1) == 0)
        return (_Yx < 0 ? static_cast<_Ty>(1) / _Zx : _Zx);
    }
}

The error is in cmath.h The error is repeated for the same line like for 25 times or so. 错误在cmath.h中。同一行重复该错误,例如25次左右。 The same for so many others. 许多其他人也一样。 (The mentioned error is the first one on the list) PS. (提到的错误是列表中的第一个)。 I added the GA files using the following sequence: 1- Project properties>C++>Additional include libraries>select folder 2- Drag-Drop the folder containing the headers and sources to the project solution manager PPS. 我按以下顺序添加了GA文件:1-项目属性> C ++>其他包含库>选择文件夹2-将包含标题和源文件的文件夹拖放到项目解决方案管理器PPS中。 All source files are with extension .C not .cpp How can I solve such situation? 所有源文件都带有扩展名.C而不是.cpp怎么解决这种情况?

Following procedures in this page: msdn.microsoft.com/en-us/library/032xwy55.aspx Most errors just vanished (including the mentioned one). 此页面中的以下步骤:msdn.microsoft.com/zh-cn/library/032xwy55.aspx大多数错误刚刚消失(包括提到的错误)。

The main problem was that the compiler deals with .C files with default option, which I changed to C++ as mentioned in aforementioned page. 主要问题是编译器使用默认选项处理.C文件,正如我在上述页面中提到的,我将其更改为C ++。

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

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