我遇到了这个
printf
实现(https://github.com/eyalroz/printf),我正在努力理解某些部分。
有这个段定义了 PRINTF_VISIBILITY
。
#ifndef PRINTF_VISIBILITY
#define PRINTF_VISIBILITY
#endif
下面几行有一些东西我不明白。
PRINTF_VISIBILITY
void putchar_(char c);
就是这样。它不包围函数声明,它不是条件或我以前见过的任何东西。它是什么以及有什么作用?
这些指令上面的评论对此进行了解释:
// 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
。