[Issue 14662] New: __FILE__ template parameter becomes relative just by changing compilation directory
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jun 7 21:08:41 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14662
Issue ID: 14662
Summary: __FILE__ template parameter becomes relative just by
changing compilation directory
Product: D
Version: D2
Hardware: x86
OS: All
Status: NEW
Severity: major
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: timothee.cour2 at gmail.com
I was getting quite obscure linker errors in a project. I reduced it to this:
__FILE__ generates sometimes relative paths even though all files and '-I'
paths are given as absolute paths, depending on the directory in which 'dmd' is
launched.
----------------------------
/mydir/fun1.d:
import fun2;
void test(){ test2(); }
/mydir/fun2.d:
void test2(string file=__FILE__)(){
if(false) test2();
}
-----------------
cd /mydir/
dmd -of/tmp/fun1.o -c -I/mydir/ /mydir/fun1.d && nm /tmp/fun1.o |ddemangle
|grep test2
S pure nothrow @nogc @safe void fun2.test2!("/mydir/fun1.d").test2()
S pure nothrow @nogc @safe void fun2.test2!("fun2.d").test2()
-----------------
cd / #or anywhere else
dmd -of/tmp/fun1.o -c -I/mydir/ /mydir/fun1.d && nm /tmp/fun1.o |ddemangle
|grep test2
S pure nothrow @nogc @safe void fun2.test2!("/mydir/fun1.d").test2()
S pure nothrow @nogc @safe void fun2.test2!("/mydir/fun1.d").test2()
The difference is: 'test2!("/mydir/fun1.d")' vs 'test2!("fun2.d")'
I believe 'test2!("fun2.d")' is wrong.
Maybe related:
http://www.digitalmars.com/d/archives/digitalmars/D/learn/exclude_current_directory_from_search_path_in_dmd_69919.html
"exclude current directory from search path in dmd ?" (which i asked on the
forum but didn't get answer to)
--
More information about the Digitalmars-d-bugs
mailing list