Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows SUA和x2B;Visual Studio+;线程_Windows_Visual Studio_Unix_Pthreads_Subsystem - Fatal编程技术网

Windows SUA和x2B;Visual Studio+;线程

Windows SUA和x2B;Visual Studio+;线程,windows,visual-studio,unix,pthreads,subsystem,Windows,Visual Studio,Unix,Pthreads,Subsystem,我无法在SUA下编译此代码: #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <pthread.h> void * thread_function(void *arg) { printf("thread_function started. Arg was %s\n", (char *)arg); // pause for 3 seconds

我无法在SUA下编译此代码:

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void * thread_function(void *arg) {
     printf("thread_function started. Arg was %s\n", (char *)arg);
     // pause for 3 seconds
     sleep(3);
     // exit and  return a message to another thread
     // that may be waiting for us to finish
     pthread_exit ("thread one all done");
}
int main() {
     int res;
     pthread_t a_thread;
     void *thread_result;
     // create a thread that starts to run     ‘thread_function’
     pthread_create (&a_thread, NULL,
     thread_function, (void*)"thread one");
     printf("Waiting for thread to finish...\n");
     // now wait for new thread to finish
     // and get any returned message in ‘thread_result’
     pthread_join(a_thread, &thread_result);
     printf("Thread joined, it returned %s\n", (char *)thread_result);
     exit(0);
}
#包括
#包括
#包括
#包括
void*thread_函数(void*arg){
printf(“线程_函数已启动。Arg为%s\n”,(char*)Arg);
//暂停3秒钟
睡眠(3);
//退出并将消息返回到另一个线程
//这可能在等待我们完成
pthread_exit(“线程一全部完成”);
}
int main(){
国际关系;
pthread_t a_线程;
无效*线程结果;
//创建一个开始运行“线程函数”的线程
pthread_create(&a_线程,NULL,
thread_函数,(void*)“thread one”);
printf(“等待线程完成…\n”);
//现在等待新线程完成
//并在“thread\u result”中获取任何返回的消息
pthread_join(线程和线程结果);
printf(“线程已加入,它返回%s\n”,(char*)线程\u结果);
出口(0);
}
我使用Visual Studio 2008和2010在Windows 7 Ultimate x64上运行,并已安装:

  • 用于UNIX的Windows子系统
  • Microsoft Windows 7和Windows Server 2008 R2中基于UNIX的应用程序子系统的实用程序和SDK
Visual Studio项目的Include Directory属性设置为“C:\Windows\SUA\usr\Include”

为了在VisualStudio2010(或2008)中编译和运行(可能还有调试)pthreads程序,我必须配置什么