__FILE__ and __LINE__ in case of import expression

Andrey Zherikov andrey.zherikov at gmail.com
Fri Aug 21 20:54:22 UTC 2020


On Friday, 21 August 2020 at 20:44:27 UTC, Andrey Zherikov wrote:
> Thanks for this link! I can use "#line" to fix line number but 
> not file name:
>
> file: 'foo.d-mixin-1', line: '6', module: 'test',
> function: 'test.main', pretty function: 'int test.main(string[] 
> args)',
> file full path: 'C:\Users\andrey\foo.d-mixin-1'

I can actually fix this issue as well.

Changes in test.d:

     test();                                          // line #16  
(1)
     mixin("#line 1 \"foo.d\"\n" ~ import("foo.d"));  // line #17  
(2)
     test();                                          // line #18  
(3)

Output:

file: 'test.d', line: '16', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] 
args)',
file full path: 'C:\Users\andrey\test.d'
file: 'foo.d', line: '6', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] 
args)',
file full path: 'C:\Users\andrey\foo.d'
file: 'test.d', line: '18', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] 
args)',
file full path: 'C:\Users\andrey\test.d'


More information about the Digitalmars-d-learn mailing list