C99 Paste by LMZ
Description: None
Hide line numbers

Create new paste
Post a reply
View replies

Paste:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
/+

catalog structure:
./main.d
./module1/myclass.d
./module2/myclass.d

+/

// ./main.d:
import module2.myclass: MyClass_2;

void main(char[][] args)
{
    MyClass_2 m = new MyClass_2();
    m.print_hello();
}

// ./module1/myclass.d:
module module1.myclass;

import tango.io.Stdout;

class MyClass_1
{
    int a = 5;
    void print_hello()
    {
        Stdout("Hello! MyClass_1").newline();
    }
}

// ./module2/myclass.d:
module module2.myclass;

import module1.myclass;
import tango.io.Stdout;


class MyClass_2: MyClass_1
{
    int a = 4;

    void print_hello()
    {
        Stdout("Hello! MyClass_2").newline();
    }
}

//
$ dmd main.d module1/myclass.d module2/myclass.d
gcc main.o myclass.o myclass.o -o main -m32 -Xlinker -L/usr/local/bin/../lib -ltango-user-dmd -ltango-base-dmd -lpthread -lm 
myclass.o: In function `_D7module27myclass9MyClass_211print_helloMFZv':
module2/myclass.d:(.text._D7module27myclass9MyClass_211print_helloMFZv+0x0): multiple definition of `_D7module27myclass9MyClass_211print_helloMFZv'
myclass.o:module2/myclass.d:(.text._D7module27myclass9MyClass_211print_helloMFZv+0x0): first defined here
myclass.o:(.rodata+0x20): multiple definition of `_D7module27myclass9MyClass_26__initZ'
myclass.o:(.rodata+0x20): first defined here
myclass.o:(.data+0x0): multiple definition of `_D7module27myclass9MyClass_27__ClassZ'
myclass.o:(.data+0x0): first defined here
myclass.o:(.rodata+0x50): multiple definition of `_D7module27myclass9MyClass_26__vtblZ'
myclass.o:(.rodata+0x50): first defined here
myclass.o:(.data+0x50): multiple definition of `_D7module27myclass12__ModuleInfoZ'
myclass.o:(.data+0x50): first defined here
myclass.o:(.data+0x28): undefined reference to `_D7module17myclass9MyClass_17__ClassZ'
myclass.o:(.data+0x88): undefined reference to `_D7module17myclass12__ModuleInfoZ'
myclass.o:(.data+0x28): undefined reference to `_D7module17myclass9MyClass_17__ClassZ'
myclass.o:(.data+0x88): undefined reference to `_D7module17myclass12__ModuleInfoZ'
collect2: ld returned 1 exit status
--- errorlevel 1


Replies:

    (some replies deleted)