宏__FILE__展开后会带有路径信息,比如下面的代码:
#include<stdio.h>
#include<stdlib.h>
int main()
{
printf("file_name:%s\n", __FILE__);
return 0;
}
如果Makefile内容如下:
CFALG = -Wall
all: /home/helloworld/test.c
gcc $(CFALG) $< -o test
编译运行,程序输出为:
file_name:/home/hello