我正在用C编写一个用户空间(目前是最小的)我正在使它像BusyBox,你可以通过调用一个带有它名字的符号链接来运行命令.我有一个"主"C文件,其中包含其中的所有其他文件(其他文件是头文件),然后如果符号链接名称匹配则运行其代码.我想知道在不同的头文件中是否可以使用相同名称的函数?
例如,如果我有thing1.h:
void help(void)
{
// Print help text for thing1
}
int thing1(int argc, char *argv[])
{
if (something)
help();
}
Run Code Online (Sandbox Code Playgroud)
而且thing2.h:
void help(void)
{
// Print help text for thing2
}
int thing2(int argc, char *argv[])
{
if (something)
help();
}
Run Code Online (Sandbox Code Playgroud)
而且everything.c:
#include "thing1.h"
#include "thing2.h"
int main(int argc, char *argv[])
{
if (something)
thing1(argc, argv);
else
thing2(argc, argv);
}
Run Code Online (Sandbox Code Playgroud)
它会更好那些帮助功能重命名为thing1_help和thing2_help分别,还是确定要离开他们,因为他们是谁?