这个#define 行的目的是什么?

问题描述 投票:0回答:1

我遇到了这个

printf
实现(https://github.com/eyalroz/printf),我正在努力理解某些部分。 有这个段定义了
PRINTF_VISIBILITY

#ifndef PRINTF_VISIBILITY
#define PRINTF_VISIBILITY
#endif

下面几行有一些东西我不明白。

PRINTF_VISIBILITY
void putchar_(char c);

就是这样。它不包围函数声明,它不是条件或我以前见过的任何东西。它是什么以及有什么作用?

c preprocessor-directive
1个回答
0
投票

这些指令上面的评论对此进行了解释:

// If you want to include this implementation file directly rather than
// link against, this will let you control the functions' visibility,
// e.g. make them static so as not to clash with other objects also
// using them.

如果您直接

#define
编辑
#define PRINTF_VISIBILITY static
文件,您可以将
static
更改为
#include
以实现所有功能
.c

© www.soinside.com 2019 - 2024. All rights reserved.