C 语言: 标记常量(void)arg;

3 阅读1分钟

阅读xcrash的代码


static void *xc_test_keep_logging(void *arg)
{
    (void)arg;
    pthread_detach(pthread_self());
    pthread_setname_np(pthread_self(), "xcrash_test_log");

    int i = 0;
    while(++i < 600)
    {
        XC_TEST_LOG("crashed APP's thread is running ...... %d", i);
        usleep(1000 * 100);
    }

    return NULL;
}
  • (void)arg; 是什么语法呢?
  • (void)arg; 是一个常见的用法,通常用于标记变量 arg(在这种情况下,是函数的参数)未被使用。这种方式通常是为了避免编译器产生未使用变量的警告。