基于jrtp库的linux多线程程序调试一

    技术2022-05-11  80

    server.c

    线程函数声明如下:

    void thread(void)

    创建线程如下:

    int id;

    int ret = pthread_create(&id,NULL,(void*)thread,NULL);

    编译语句如下:

    arm-linux-g++ server.c -ljrtp -lpthread -o server

    错误提示:

    ANSI C++ forbids implicit conversion from `void *' in argument passing

      解决:

    int ret = pthread_create(&id,NULL,(void*(*)(void*)thread,NULL);

    或者:(没有验证)

    void *(*start_routine)(void*)就是需要的函数原型。void* thread(void*){ ...}


    最新回复(0)