clang 3.3 可以在 VS 2010 中使用命名空间编译代码
clang 3.3 can compile the code with namespace in vs 2010?
当我在 Ubuntu 系统上使用 clang 3.3 编译程序时,错误对我来说很难。 源代码如下:
#include <iostream>
using namespace std;
int main()
{
cout<<"hello world!"
return 0;
}
代码是在 vs 2010 上编程的,所以命令行是:
clang++ -c -g -fms-compatibility -fdelayed-template-parsing -I /home/qincai/桌面/IRSA/IRSA/IRSA/vcinclude -emit-llvm -fmacro-backtrace-limit=0 -std=c++11 -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-ignored-attributes -Wno-attributes -Wno-implicit-exception-spec-mismatch -Wno-deprecated-declarations -Wno-unused-value -imacros macro.h -Wno-microsoft teststd.cpp -o teststd.o
vcinclude
是VS2010的目录,包括文件和从Windows系统复制。错误如下:
(1)ios:13:1: error: expected member
name or ';' after declaration specifiers
_STD_BEGIN
^~~~~~~~~~
/home/qincai/桌面/IRSA/IRSA/IRSA/vcinclude/yvals.h:488:22: note: expanded from
macro '_STD_BEGIN'
#define _STD_BEGIN namespace std {
^~~~~~~~~
是说 clang 不能在 vc ++ 中编译命名空间吗?如果 clang 可以编译命名空间,如何处理?
虽然只要您编写标准C++,您自己的C++代码就可以移植,但一个特定编译器提供的C++标准库的头文件不能保证,而且几乎永远不会可移植到另一个编译器。
您不能将Visual Studio 2010的头文件与Ubuntu上的clang一起使用。
您的代码在cout<<"hello world!"
末尾也缺少;
相关文章:
- 如何使用 soong 命名空间来有条件地编译模块
- 使用 make 编译 MPI,几个命名空间错误,例如"错误:未知类型名称'使用'?
- 无法获取 wig %ignore 以忽略命名空间中的类,从而导致编译错误
- C++ 使用命名空间时,模板函数无法使用 g++ 进行编译
- 非命名空间范围内的显式专用化不会在 GCC 中编译
- 库期望平面命名空间中的符号,尽管使用两级命名空间编译
- 在命名空间中使用自己的类比较 std::vector 不会编译
- 使用命名空间别名编译 OpenCV
- 包含命名空间的类模板的前向声明会导致编译错误
- C2653:不是没有预编译标头的类或命名空间
- 每个编译单元是否只有一个未命名的命名空间
- 命名空间 X 中具有类 X 的模板类 Y 无法在 VS2010 中编译
- 是否可以在编译时获得一个包含命名空间和类名的字符串
- C++中的编译错误可能是命名空间问题
- clang 3.3 可以在 VS 2010 中使用命名空间编译代码
- 为什么 rand() 在不包含 cstdlib 或使用命名空间 std 的情况下编译
- 什么是“使用命名空间 std;”,为什么我需要它来编译具有最新C++编译器的程序
- C++ 全局命名空间编译问题
- 为什么结构必须与模板类位于同一命名空间中才能编译
- 命名空间编译问题