Skip to content

Commit 4844d27

Browse files
committed
Global C++ constructors and destructors work again. Fixes #42.
1 parent b31cf92 commit 4844d27

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

examples/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ BINS = hello-ks13 hello-ks20 hello-ks20.clib2 \
77
hello-stdio hello-stdio.clib2 hello-stdio.nix13 \
88
hello-mui test-mmu \
99
simple.library simple.library_r simple.device \
10-
hello-iostream
10+
test-ctors hello-iostream
1111

1212
all: $(BINS) $(OBJS)
1313

@@ -30,7 +30,13 @@ hello-stdio.clib2: hello-stdio.c
3030
$(CC) -mcrt=clib2 -m68020 $(CFLAGS) -o $@ $<
3131

3232
hello-iostream: hello-iostream.cpp
33-
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ $<
33+
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ $^
34+
35+
test-ctors: test-ctors.cpp
36+
$(CXX) -noixemul -m68020 $(CXXFLAGS) -D__A -c -o test-ctors-a.o $<
37+
$(CXX) -noixemul -m68020 $(CXXFLAGS) -D__B -c -o test-ctors-b.o $<
38+
$(CXX) -noixemul -m68020 $(CXXFLAGS) -c -o test-ctors.o $<
39+
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ test-ctors*.o
3440

3541
hello-mui: hello-mui.c
3642
$(CC) -noixemul -m68020 -msmall-code $(CFLAGS) -o $@ $< -lmui

examples/test-ctors.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
3+
#ifdef __A
4+
struct A {
5+
int i;
6+
A(int _i) { i = _i; puts("ctor A"); }
7+
~A() { puts("dtor A"); }
8+
};
9+
10+
A a(10);
11+
#endif
12+
13+
#ifdef __B
14+
struct B {
15+
int i;
16+
B(int _i) { i = _i; puts("ctor B"); }
17+
~B() { puts("dtor B"); }
18+
};
19+
20+
B b(20);
21+
#endif
22+
23+
#if !defined(__A) && !defined(__B)
24+
int main()
25+
{
26+
puts("hello world!");
27+
return 0;
28+
}
29+
#endif

submodules/gcc-2.95.3

Submodule gcc-2.95.3 updated from 965e443 to f25bf19

submodules/libnix

Submodule libnix updated from b1c9ff1 to 7ab6f71

0 commit comments

Comments
 (0)