C ++ eclipse多线程错误

时间:2017-07-24 12:27:08

标签: c++ eclipse multithreading

这是我第一次在Eclipse下调试c ++多线程程序,无法解决以下错误。

#include <iostream>
#include <pthread.h>

using namespace std;
#define NUM_THREADS 5

void* say_hello(void* args)
{
    cout << "Hello World" << endl;
}

int main()
{
    pthread_t tids[NUM_THREADS];
    for(int i = 0; i < NUM_THREADS; ++i)
    {
        int ret = pthread_create(&tids[i], NULL, say_hello, NULL);
        if (ret != 0)
        {
           cout << "pthread_create error: error_code=" << ret << endl;
        }
    }
    pthread_exit(NULL);
}

控制台日志是:

21:50:36 **** Incremental Build of configuration Debug for project thread1 ****
> make all  Building file: ../src/thread1.cpp Invoking: GCC C++ Compiler
> g++ -Ipthread -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP
> -MF"src/thread1.d" -MT"src/thread1.d" -o "src/thread1.o" "../src/thread1.cpp" ../src/thread1.cpp: In function ‘void*
> say_hello(void*)’: ../src/thread1.cpp:10:1: warning: no return
> statement in function returning non-void [-Wreturn-type]  }  ^
> Finished building: ../src/thread1.cpp   Building target: thread1
> Invoking: GCC C++ Linker g++  -o "thread1"  ./src/thread1.o  
> -lpthread Finished building target: thread1  
> 
> 21:50:37 Build Finished (took 545ms)

有人可以指出我的错误在哪里吗?谢谢你的帮助。

0 个答案:

没有答案