- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下代码(用于检测编译器是否支持C++14):
#include <memory>
#include <algorithm>
// Check the version language macro, but skip MSVC because
// MSVC reports 199711 even in MSVC 2017.
#if __cplusplus < 201402L && !defined(_MSC_VER) && !defined(__INTEL_COMPILER)
#error "insufficient support for C++14"
#endif
int main()
{
auto ptr = std::make_unique<int>(42);
constexpr int max = std::max(0, 1);
(void) ptr;
(void) max;
return 0;
}
当使用 g++
(版本 11.2.1)和 g++ -std=c++14 test.cpp -o test
行编译时,它工作正常。当使用 intel 编译器(版本 2021.3.0(gcc 版本 11.2.1 兼容性))而不是使用 icpc -std=c++14 test.cpp -o test
编译它时,它失败了
In file included from /usr/include/c++/11/cwchar(44),
from /usr/include/c++/11/bits/postypes.h(40),
from /usr/include/c++/11/iosfwd(40),
from /usr/include/c++/11/bits/shared_ptr.h(52),
from /usr/include/c++/11/memory(77),
from test.cpp(1):
/usr/include/wchar.h(155): error: attribute "__malloc__" does not take arguments
__attribute_malloc__ __attr_dealloc_free;
^
In file included from /usr/include/c++/11/cstdlib(75),
from /usr/include/c++/11/bits/stl_algo.h(59),
from /usr/include/c++/11/algorithm(62),
from test.cpp(2):
/usr/include/stdlib.h(565): error: attribute "__malloc__" does not take arguments
__attr_dealloc_free;
^
In file included from /usr/include/c++/11/cstdlib(75),
from /usr/include/c++/11/bits/stl_algo.h(59),
from /usr/include/c++/11/algorithm(62),
from test.cpp(2):
/usr/include/stdlib.h(569): error: attribute "__malloc__" does not take arguments
__THROW __attr_dealloc (reallocarray, 1);
^
In file included from /usr/include/c++/11/cstdlib(75),
from /usr/include/c++/11/bits/stl_algo.h(59),
from /usr/include/c++/11/algorithm(62),
from test.cpp(2):
/usr/include/stdlib.h(797): error: attribute "__malloc__" does not take arguments
__attr_dealloc_free __wur;
^
compilation aborted for test.cpp (code 2)
这里到底出了什么问题,我该如何解决?
简短更新:看起来 CUDA 遇到了类似的问题,它可能与 glibc 2.34 有关:https://forums.developer.nvidia.com/t/cuda-11-5-samples-throw-multiple-error-attribute-malloc-does-not-take-arguments/192750/15
最佳答案
使用icpc 2021.4编译并执行共享代码,运行良好。
使用下面的命令来编译代码。icpc -std=c++14
下面是环境的详细信息。
操作系统:Ubuntu 18.04.3 LTS内核:Linux 4.15.0-76-generic
关于兼容性,请引用英特尔® C++ 编译器经典系统要求链接
关于c++ - 英特尔编译器无法使用 `attribute "__malloc_ _"does not take arguments` 进行 C++14 检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69404834/
我有以下代码(用于检测编译器是否支持C++14): #include #include // Check the version language macro, but skip MSVC bec
我是一名优秀的程序员,十分优秀!