C++错误:'inline'只能出现在函数上
C++ error: 'inline' can only appear on functions
我正在尝试使用clang++在OS X 10.7下编译VCMI。
我用CXX=clang++
配置了项目,因为苹果的 gcc 似乎无法识别所需的-std=c++0x
标志。
我在CXXFLAGS
中添加了-stdlib=libc++
,因为没有那个叮当甚至无法找到#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 的宏,然后包括标准标头,是未定义的行为。
IIRC,较新版本的libc ++避免使用名称_T特别是因为人们倾向于搞砸它,因此您可能想尝试升级到最新版本的命令行工具。
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 激励'inline'说明符的真实世界示例?
- 'inline'变量可以像内联函数一样内联吗?
- C++不使用"inline"或"static"无类函数的关键字时出现重定义链接错误
- 将新元素推送到函数指针映射中 "inline" ?
- 在头文件中实现的函数的static与inline
- 成员函数模板"inline"需要
- C++错误:'inline'只能出现在函数上
- 什么是'extern inline'函数以及何时使用?
- "inline"隐式于类定义中定义的C++成员函数中
- 'inline'__global__函数以避免多个定义错误
- 我应该在频繁使用的函数上使用“inline”吗?
- c++实现了friend/inline函数
- 让函数包装器与inline一起工作
- 替换函数'operator new'不能声明'inline' [-werror,-winline-new-delete]
- "在线好友…"有什么区别函数和`friend inline…`功能
- 包装INLINE函数
- 模板' inline '函数的静态局部变量
- "inline"函数定义的目的是什么?