无法在cygwin上编译故意的文件

时间:2016-06-16 07:18:14

标签: c++ g++ cygwin clang++

编译vim插件color_coded时会出现问题,可归纳如下:

  1. 使用g++ -std=c++14symlink无法找到unistd.h
  2. 使用clang++ -std=c++14,cygwin不支持mutex
  3. 那么,如何在cygwin上编译这段代码?

    #include <unistd.h>
    #include <mutex>
    #include <thread>
    #include <iostream>
    
    std::mutex io_mutex;
    auto foo(){
       std::lock_guard<std::mutex> guard{io_mutex};
       std::cout << &symlink << "\n";
    }
    
    int main(){
       std::thread t1{foo}, t2{foo};
       t1.join();
       t2.join();
    }
    

    以下是错误。

    1. gcc 5.4.0g++ -std=c++14

      t.cpp: In function 'auto foo()':
      t.cpp:9:18: error: 'symlink' was not declared in this scope
          std::cout << &symlink << "\n";
      
    2. 使用clang 3.7.1clang++ -std=c++14

      In file included from t.cpp:2:
      /usr/lib/gcc/i686-pc-cygwin/5.4.0/include/c++/mutex:699:10: error: thread-local
            storage is not supported for the current target
        extern __thread void* __once_callable;
               ^
      /usr/lib/gcc/i686-pc-cygwin/5.4.0/include/c++/mutex:700:10: error: thread-local
            storage is not supported for the current target
        extern __thread void (*__once_call)();
               ^
      2 errors generated.
      

0 个答案:

没有答案