i’m using this code on AIX/HP-UX/LINUX, but when i try to run it on Mac os x it dont work well:
pthread_t m_thread;
int merror;//thread return
cout << "init" << endl;
if (m_thread != NULL){
cout << "running" << endl;
merror= pthread_create(&m_thread, NULL, _exec, NULL);//initialize thread
}
On linux the pthread is created and the running message appears on the screen.
But on Mac os x the m_thread returns null, so o can’t execute the same code on MAC OS X, someone know why it’s happening.
The compiling code: g++ -g -o sclient sclient.cpp socket.cpp -pthread -lpthread -thread
You shouldn’t check
m_thread != NULL, it makes no sense. Remove that check and it should work fine.