c/C++의 macro__FILE__에는 컴파일 된 위치의 파일 경로가 포함되어 있습니다. 예를 들어 :매크로 __FILE__의 그라데이션이 이상한 동작
gcc test.c -o test
./test
test.c
gcc myFolder/test.c -o test
./test
myFolder/test.c
하지만 Gradle을 컴파일 할 때, 그것을 출력처럼 내 파일의 전체 경로 :
home/usr/myFolder/test.c.
내가 macro__FILE__는 내부 프로젝트 경로를 포함하지만 미리 컴파일 할 완전한.
Gradle을 파일 :
apply plugin: 'c'
model {
components {
main(NativeExecutableSpec) {
sources {
c {
source {
srcDir "./"
include "*.c"
}
}
}
}
}
}
TEST.C :
#include <stdio.h>
void main(void)
{
printf("%s\n", __FILE__);
}