【问题标题】:eclipse CDT shows Invalid arguments ' Candidates are: ... ' for lambda expressionseclipse CDT 显示 Invalid arguments ' Candidates are: ... ' 用于 lambda 表达式
【发布时间】:2020-09-08 10:26:31
【问题描述】:

面向 C/C++ 开发人员的 Eclipse IDE(包括孵化组件)
版本:2020-06 (4.16.0)
内部版本号:20200615-1200

C/C++ 开发工具
版本:9.11.1.202006011430
内部版本号:20200601-1605

带有 gcc 10.2.0 的 Arch Linux

给出以下最小示例

#include <cstdint>
#include <functional>

struct LinkedElement {
    uint8_t index = 0;
    LinkedElement* next = nullptr;
};

static LinkedElement* linkedList;

LinkedElement* FindLinkedElement(std::function<bool(LinkedElement*)> filter)
{
    for (auto elem = linkedList; elem != nullptr; elem = elem->next)
    {
        if (filter(elem))
        {
            return elem;
        }
    }
    return nullptr;
}

int main(int argc, char **argv) {
    auto broken = FindLinkedElement([](LinkedElement* le){ return le->index > 0; });
    auto works = FindLinkedElement(nullptr);
}

eclipse 会将main() 中的第一个FindLinkedElement 下划线作为“语义错误”(由“问题”视图确定)并带有以下错误消息

Invalid arguments '
Candidates are:
LinkedElement * FindLinkedElement(std::function<bool (LinkedElement *)>)
'

第二行未标记为错误。编译器对所有这些代码都很好。如何让 eclipse 不将此视为错误?

【问题讨论】:

    标签: c++ lambda eclipse-cdt


    【解决方案1】:

    看起来问题出在arm-none-eabi-gcc 10.2.0。现在运行 9_2020_q2_update 我在 eclipse 中看不到更多错误。

    【讨论】:

      猜你喜欢
      • 2012-10-12
      • 1970-01-01
      • 2011-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多