C “做什么?”;(无效)<;参数>&引用;是吗?
我在看这个例子,我看到一个非常奇怪的结构。以下是让我困惑的摘录:C “做什么?”;(无效)<;参数>&引用;是吗?,c,C,我在看这个例子,我看到一个非常奇怪的结构。以下是让我困惑的摘录: static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { (void) offset; (void) fi; if (strcmp(path, "/") != 0) return -
static int hello_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
(void) offset;
(void) fi;
if (strcmp(path, "/") != 0)
return -ENOENT;
filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, hello_path + 1, NULL, 0);
return 0;
}
如您所见,此函数中要做的第一件事是
(void)offset代码>和<代码>(无效)fi代码>。这到底有什么作用?防止lint或编译器发出“未使用变量”警告是一种常见的技术。另见: