[Issue 8856] import inside function sometimes causes link errors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 19 20:18:52 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8856



--- Comment #2 from thelastmammoth at gmail.com 2012-10-19 20:18:49 PDT ---
(In reply to comment #1)
> We'll need a failing test-case. What contents cause the linker error?

here's a failure case which I simplified to the maximum.
Note that link error occurs with rdmd, not with dmd, as shown below. So that is
a problem with rdmd failing to find dependencies in some cases.

----
rdmd ${DFLAGS} main

=>Undefined symbols for architecture x86_64:
"_D9main_aux24fun1FZv", referenced from:
_D8main_aux4testFZv in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

----
dmd ${DFLAGS} main main_aux main_aux2
=> works
----

Here are the files:

.
├── main.d
├── main_aux.d
└── main_aux2.d

cat  main.d                                                                    
                                                                            
import main_aux;
void main(){
    test;
}                                                                               
cat main_aux.d
module main_aux;
//putting the main function here removes link error
//void main(){
//    test;
//}

//import main_aux2; //uncomment removes link error
void test(){
    import main_aux2;
    fun1();
}

cat main_aux2.d
module main_aux2;
void fun1() {
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list