下面代码中 如果是#if 1 ,程序运行起来会出cor dumped,如标题。
如果是#if 0 正常创建线程没有问题,谁知道是什么原因。
#if 1
bt_pthread_create();
#else
pthread_t id;
int ret;
ret = pthread_create(id, NULL, (void*)tasksub, NULL);
#endif
完整代码
====================================================================
#include "stdio.h"
#include "bt_if_lib.h"
#include <pthread.h>
extern void tasksub(void);
void bt_pthread_create(void);
void bt_pthread_create(void)
{
pthread_t id;
int ret;
ret = pthread_create(id, NULL, (void*)tasksub, NULL);
}
void main(void)
{
int i;
printf("HMI Main START\n");
I_bt_init();
sleep(10);
#if 1 // 问题位置,这样就会Coredump #if 0 就没有问题,函数里面代码和else中是一样的,拷贝过去的。
bt_pthread_create();
#else
pthread_t id;
int ret;
ret = pthread_create(id, NULL, (void*)tasksub, NULL);
#endif
for(i=0;i<50;i++)
{
I_bt_audio_play();
sleep(5);
}
while(1) //T.B.D
{
printf("HMI Main While\n");
sleep(100);
}
}
==================================================================================