__FILE__

workman workman at gmail.com
Mon Jul 26 11:43:56 UTC 2021


file test.d:

     -------------
     module test;
     import abc;
     void doTest(){
     	log!"test"();
     }
     -----------

     file abc.d:
     -------------
     module abc;
     import test;
     void log(string fmt, int line = __LINE__, string path = 
__FILE__[0..$], A...)(A a) {
     	import core.stdc.stdio;
     	printf("[%s:%d] \n", path.ptr, line);
     }
     extern(C) int main() {
     	doTest();
     	return 0;
     }

-------------

retult: [abc.d:4]

expect: [test.d:4]


More information about the Digitalmars-d-learn mailing list