gpt4 book ai didi

c++ - 使用 uclibc 编译已删除的函数失败

转载 作者:行者123 更新时间:2023-11-30 02:18:30 26 4
gpt4 key购买 nike

我有一个项目要从 glibc 移植到 uclibc,但遇到了这个问题。

gcc --std=c++11 Foo.cpp -o Foo-glibc
x86_64-linux-uclibc-gcc --std=c++11 Foo.cpp -o Foo-uclibc

// Compiles under glibc and uclibc
class Foo {
Foo() = default;
Foo(const Foo& arg) = delete;
~Foo() = default;
};

// Only compiles under glibc
class Foo {
Foo() = default;
Foo(const Foo& arg);
~Foo() = default;
};
Foo::Foo(const Foo& arg) = delete; // uclibc - Error: deleted definition of 'Foo::Foo(const Foo&)'

为什么会出现这个错误?这是预期的行为吗?我读过的任何内容都表明 uclibc 不应该能够处理这个问题。

最佳答案

这很可能是旧 gcc 版本中的错误。

在 4.8.5 中它 worked , 但在 5.1.0 中它是 doesn't .

引用 Alan Birtles 的话

[I]t makes no sense to declare a constructor in the class declaration[,] then delete it out of line. How would a consumer of the class know that the constructor is deleted?

关于c++ - 使用 uclibc 编译已删除的函数失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52098695/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com