pthread_t on mac os x is NULL
pthread_t on mac os x is NULL
我在AIX/H-UX/LINUX上使用这段代码,但当我尝试在Mac os x上运行它时,它运行不好:
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
}
在linux上,pthread被创建,并且运行消息显示在屏幕上。但在Mac os x上,m_thread返回null,因此o无法在Mac os上执行相同的代码,有人知道为什么会发生这种情况。
编译代码:g++-g-o sclient sclient.cpp socket.cpp-phread-lpthread-thread
您不应该检查m_thread != NULL
,这毫无意义。去掉那张支票,它应该能正常工作。
在进行测试时,您还没有初始化m_thread
——它的值是不确定的。
相关文章:
- 如果我std::dynamic_pointer_cast并且底层dynamic_cast的结果为null,那么返回的sh
- 如何在 c++ 中'NULL'字符串
- c++使用foreach使数组为null
- 当使用通配符和null指针调用函数时,对输出的说明
- Why is UINT32_MAX + 1 = 0?
- C++错误:"error: int aaa::bbb is protected within this context"
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 当字段可以为null时,如何使用C++接口在Avro中写入数据
- 如何在映射中返回null
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- Is !NaN not a NaN?
- 为什么返回 NULL 不会破坏函数?
- 构造函数中的 QQuickItem 父项 null
- Directx 11 - CompileFromFile() is not compiling
- 检查字符串是否"null" C++
- Centos7 g++ "to_string is not in a member of std"
- getProcAddress - NULL is returned
- pthread_t on mac os x is NULL
- Is it safe to #define NULL nullptr?
- Freeglut fgInitGL2: fghGenBuffers is NULL