2
0
mirror of https://frontier.innolan.net/github/amigaos-cross-toolchain6.git synced 2024-10-19 10:29:55 +00:00

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