Jon*_*art 15
单个程序可以包含多个 C文件.那你要找哪一个?
该__FILE__
宏被这个原因作出.它由预处理器替换,其中包含正在编译的当前源(.C)文件的名称.
main.c中
#include <stdio.h>
int main(int argc, char** argv)
{
printf("Executable name: %s\n", argv[0]);
printf("This is %s() from %s, line %d\n",
__FUNCTION__, __FILE__, __LINE__);
one();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
one.c
#include <stdio.h>
void one(void)
{
printf("This is %s() from %s, line %d\n",
__FUNCTION__, __FILE__, __LINE__);
}
Run Code Online (Sandbox Code Playgroud)
输出(假设可执行文件名为"hello.exe"):
Executable name: hello.exe
This is main() from main.c, line 4
This is one() from one.c, line 3
Run Code Online (Sandbox Code Playgroud)
也可以看看:
归档时间: |
|
查看次数: |
10191 次 |
最近记录: |