clang 3.3 可以在 VS 2010 中使用命名空间编译代码

clang 3.3 can compile the code with namespace in vs 2010?

本文关键字:命名空间 编译 代码 2010 VS clang      更新时间:2023-10-16

当我在 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!"末尾也缺少;