自201903-R版本以来,Eclipse显示聚合/括号初始化错误

时间:2019-07-01 14:20:58

标签: c++ eclipse ide

在更新到eclipse 2019-03-R或2019-06-R eclipse之后,显示括号初始化错误。

例如

无效的参数

std::string portStr{cfg.portStrInit};

符号'counterStr'无法解析

    class Counter
    {
      private:
        std::string counterStr {};

      public:
        Counter(std::string _counterStr) : counterStr{_counterStr}
    }

我们的Windriver编译器会编译2018-12-R及更早版本的代码和eclipse版本。

问题发生在复杂的类型上,例如std :: string,std :: vector,自己定义的类...

使用简单类型int,long等可用于Eclipse。 例如

int test{cfg.testInit};

std:string{"Initializing with string and not with variable works for eclipse."};

确保在传递复杂类型的变量时,最好使用()而不是{}进行初始化。我仍然很惊讶我们的编译器没有抱怨这种初始化。

    std::string portStr(cfg.portStrInit); accepted by eclipse instead of

    std::string portStr{cfg.portStrInit} not accepted by eclipse;

但这是增长的代码,我们不想更改数百行以满足日食。

对于复杂类型,是否有可能使eclipse用{}接受这种初始化?

0 个答案:

没有答案