diff --git a/Makefile b/Makefile index 3ed95c2..5a71bb7 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ exe: $(EXE) dll: $(DLL) windows: ALL_CXXFLAGS += $(OPT_FLAGS) +windows: ALL_CXXFLAGS += -mstackrealign windows: dll linux: ALL_CXXFLAGS += $(OPT_FLAGS) -fpic diff --git a/README.md b/README.md index 71ed4a9..558ea8c 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ and odds are that your version is horribly outdated anyway. *Debian/Ubuntu users:* your stable version of g++ can't even build this. just `apt-get install clang-3.6` and export `CXX=clang++-3.6` when building. +If you really have to use g++, +you may need to add `-fabi-version=6` to CXXFLAGS. + ### general building `make linux` or `make windows` (works well with [mxe]) diff --git a/include/Aligned.hpp b/include/Aligned.hpp new file mode 100644 index 0000000..5582cbc --- /dev/null +++ b/include/Aligned.hpp @@ -0,0 +1,22 @@ +// http://stackoverflow.com/a/18137117 +struct Aligned { + static void* + operator new(size_t sz) { + const size_t extra = sizeof(void *); + void *mem = new char[sz + extra + 15]; + void *aligned = (void *)( + ((uintptr_t)(mem) + extra + 15) & ~15 + ); + void **ptr = (void **)(aligned); + ptr[-1] = mem; + return aligned; + } + + static void + operator delete(void* aligned, size_t sz) + { + void **ptr = (void **) aligned; + char *mem = (char *)(ptr[-1]); + delete[] mem; + } +}; diff --git a/include/Crap.hpp b/include/Crap.hpp index 093cc24..4b97922 100644 --- a/include/Crap.hpp +++ b/include/Crap.hpp @@ -1,4 +1,6 @@ -struct Crap { +#include "Aligned.hpp" + +struct Crap : public Aligned { virtual inline ~Crap() {} diff --git a/template/ladspa.cpp b/template/ladspa.cpp index 8b84c4b..b06c4d6 100644 --- a/template/ladspa.cpp +++ b/template/ladspa.cpp @@ -1,4 +1,5 @@ #include + #include "ladspa.hpp" //#INCLUDE