SUA + Visual Studio + потоки - PullRequest
1 голос
/ 29 марта 2010

Я не могу скомпилировать этот код в 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);
}

Я работаю на Windows 7 Ultimate x64 с Visual Studio 2008 и 2010 и установил:

  • Подсистема Windows для UNIX
  • Утилиты и SDK для подсистемы для приложений на базе UNIX в Microsoft Windows 7 и Windows Server 2008 R2

Свойство «Включить каталоги» проекта Visual Studio имеет значение «C: \ Windows \ SUA \ usr \ include»

Что мне нужно настроить, чтобы компилировать и запускать (и, возможно, отлаживать) программы pthreads в Visual Studio 2010 (или 2008)?

...