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]
  • __FILE__ workman via Digitalmars-d-learn

Reply via email to