gpt4 book ai didi

C++ 错误 : 'inline' can only appear on functions

转载 作者:搜寻专家 更新时间:2023-10-31 00:42:31 24 4
gpt4 key购买 nike

我正在尝试编译 VCMI在 OS X 10.7 下使用 clang++。

我用 CXX=clang++ 配置了项目因为 Apple 的 gcc 似乎无法识别所需的 -std=c++0x旗帜。

我添加了 -stdlib=libc++CXXFLAGS因为没有那个 clang 甚至无法找到 #include <array> .

目前我有:CXXFLAGS= -std=c++0x -stdlib=libc++ -Wall -Wextra -Wcast-align -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wc++11-extensions

问题是我收到以下错误:

clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior    is deprecated
clang: warning: argument unused during compilation: '-ggdb'
StdInc.h:1:9: warning: #pragma once in main file
#pragma once
^
In file included from StdInc.h:3:
In file included from ./../Global.h:32:
In file included from /usr/bin/../lib/c++/v1/algorithm:594:
In file included from /usr/bin/../lib/c++/v1/memory:596:
/usr/bin/../lib/c++/v1/iterator:1696:1: error: 'inline' can only appear on functions
inline _LIBCPP_INLINE_VISIBILITY
^
/usr/bin/../lib/c++/v1/iterator:1698:1: error: variable 'begin' declared as a template
begin(_T (&__array)[_N])
^
/usr/bin/../lib/c++/v1/iterator:1698:12: error: use of undeclared identifier '__array'
begin(_T (&__array)[_N])
^
./../tchar_amigaos4.h:157:16: note: expanded from macro '_T'
#define _T(x) x
^
In file included from StdInc.h:3:
In file included from ./../Global.h:32:
In file included from /usr/bin/../lib/c++/v1/algorithm:594:
In file included from /usr/bin/../lib/c++/v1/memory:596:
/usr/bin/../lib/c++/v1/iterator:1698:25: error: expected ';' at end of declaration
begin(_T (&__array)[_N])
^
;
/usr/bin/../lib/c++/v1/iterator:1699:1: error: expected unqualified-id
{
^
1 warning and 5 errors generated.

我必须承认,我从未见过这样的事情。这些在 libc++ 源代码中!有谁知道可能是什么原因吗?

最佳答案

您的问题在这里:

./../tchar_amigaos4.h:157:16: note: expanded from macro '_T'
#define _T(x) x

严格来说,在您的代码中定义一个名为 _T 的宏,然后包含标准 header 是未定义的行为。

IIRC,较新版本的 libc++ 尤其要避免使用名称 _T,因为人们往往会把它搞砸,因此您可能想尝试升级到最新版本的命令行工具。

关于C++ 错误 : 'inline' can only appear on functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11969908/

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