从不兼容的指针类型分配

Hri*_*sto 6 c struct pointers typedef

我已经设置了以下结构:

typedef struct _thread_node_t {
    pthread_t thread;
    struct thread_node_t *next;
} thread_node_t;
Run Code Online (Sandbox Code Playgroud)

......然后我定义了:

// create thread to for incoming connection
thread_node_t *thread_node = (thread_node_t*) malloc(sizeof(thread_node_t));
pthread_create(&(thread_node->thread), NULL, client_thread, &csFD);

thread_node->next = thread_arr; // assignment from incompatible pointer type

thread_arr = thread_node;
Run Code Online (Sandbox Code Playgroud)

thread_arr的位置 thread_node_t *thread_arr = NULL;

我不明白为什么编译器在抱怨.也许我误会了什么.

N 1*_*1.1 5

struct thread_node_t *next;应该struct _thread_node_t *next;


此外,取消明确的演员表.

thread_node_t *thread_node = (thread_node_t*) malloc(sizeof(thread_node_t));
Run Code Online (Sandbox Code Playgroud)

thread_node_t *thread_node = malloc(sizeof(thread_node_t));
Run Code Online (Sandbox Code Playgroud)