Global C++ constructors and destructors work again. Fixes #42.

This commit is contained in:
Krystian Bacławski 2016-10-15 11:32:17 +02:00
parent b31cf92b2e
commit 4844d27b84
4 changed files with 39 additions and 4 deletions

View File

@ -7,7 +7,7 @@ BINS = hello-ks13 hello-ks20 hello-ks20.clib2 \
hello-stdio hello-stdio.clib2 hello-stdio.nix13 \
hello-mui test-mmu \
simple.library simple.library_r simple.device \
hello-iostream
test-ctors hello-iostream
all: $(BINS) $(OBJS)
@ -30,7 +30,13 @@ hello-stdio.clib2: hello-stdio.c
$(CC) -mcrt=clib2 -m68020 $(CFLAGS) -o $@ $<
hello-iostream: hello-iostream.cpp
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ $<
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ $^
test-ctors: test-ctors.cpp
$(CXX) -noixemul -m68020 $(CXXFLAGS) -D__A -c -o test-ctors-a.o $<
$(CXX) -noixemul -m68020 $(CXXFLAGS) -D__B -c -o test-ctors-b.o $<
$(CXX) -noixemul -m68020 $(CXXFLAGS) -c -o test-ctors.o $<
$(CXX) -noixemul -m68020 $(CXXFLAGS) -o $@ test-ctors*.o
hello-mui: hello-mui.c
$(CC) -noixemul -m68020 -msmall-code $(CFLAGS) -o $@ $< -lmui

29
examples/test-ctors.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <stdio.h>
#ifdef __A
struct A {
int i;
A(int _i) { i = _i; puts("ctor A"); }
~A() { puts("dtor A"); }
};
A a(10);
#endif
#ifdef __B
struct B {
int i;
B(int _i) { i = _i; puts("ctor B"); }
~B() { puts("dtor B"); }
};
B b(20);
#endif
#if !defined(__A) && !defined(__B)
int main()
{
puts("hello world!");
return 0;
}
#endif

@ -1 +1 @@
Subproject commit 965e443fcfaa8607aa88791df6faf70132be0a83
Subproject commit f25bf1943600988cf2c9a91f05eb131d0908d2c2

@ -1 +1 @@
Subproject commit b1c9ff1a739e5726416f73b9e528f639df9a2717
Subproject commit 7ab6f718046681efd4ce5c20babdf3fab99cab61