C语言函数Void* 和Void

void

对于该函数,函数参数是void (*routine)(void *),则可以创建下面这个函数来对应。

void pthread_cleanup_push(void (*routine)(void *), void *arg);
static void cleanup(void *arg)
{
    printf("cleanup: %s\n", (char *)arg);
}

且由于是void类型所以该函数没有返回值。

调用方法:

pthread_cleanup_push(cleanup, "第 1 次调用");

Void *

对于该线程创建函数

int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);

以参数代码void *(*start_routine) (void *)为例,该参数创建函数为

static void *new_thread_start(void *arg)
{
printf("新线程: 进程 ID<%d> 线程 ID<%lu>\n", getpid(), pthread_self());
return (void *)0;
}

返回值为void *类型即可。

使用方法

ret = pthread_create(&tid, NULL, new_thread_start, NULL);

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值