diff --git a/dpf b/dpf index 1d756d6..6bf4d68 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit 1d756d6ac203d5c133769e1f5930f3dac7edb9bc +Subproject commit 6bf4d68dec211900a3f3e184678a904919e4aabc diff --git a/include/mingw-compat/cstdio b/include/mingw-compat/cstdio new file mode 100644 index 0000000..28cecb7 --- /dev/null +++ b/include/mingw-compat/cstdio @@ -0,0 +1,59 @@ +/* + * DISTRHO Cardinal Plugin + * Copyright (C) 2021 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the LICENSE file. + */ + +#pragma once + +/* On mingw stdio functions like printf are not inline, and thus get defined every time they are used. + * Its also does `#undef printf` which invalidates our macros :( + * We go through a few steps to ensure unique symbol names. + */ +#ifdef STDIO_OVERRIDE + +// helper macros +# define STDIO_OVERRIDE_HELPER(NS, SEP, FN) NS ## SEP ## FN +# define STDIO_OVERRIDE_MACRO(NS, FN) STDIO_OVERRIDE_HELPER(NS, _, FN) + +// step 1: prefix the needed stdio functions +# define printf STDIO_OVERRIDE_MACRO(STDIO_OVERRIDE, printf) + +// step 2: inlude which will use our prefixed names +# include + +// step 3: undef and define dummy functions required for (it uses `using ::printf` syntax) +# undef printf +static inline void printf() {} + +// step 4: we can safely include now +# include_next + +// step 5: define the same macros as in step 1 +# define printf STDIO_OVERRIDE_MACRO(STDIO_OVERRIDE, printf) + +// step 6: place the macro prefixed names in std namespace +namespace std { + using ::printf; +} + +// extra, there might be warnings for GCC format attribute, ignore those +#pragma GCC diagnostic ignored "-Wformat" + +#else // STDIO_OVERRIDE + +// if STDIO_OVERRIDE is not defined, we have nothing to do +# include_next + +#endif // STDIO_OVERRIDE diff --git a/plugins/Makefile b/plugins/Makefile index 0bfdafe..a11402c 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -837,7 +837,8 @@ $(BUILD_DIR)/ValleyAudio/%.cpp.o: ValleyAudio/%.cpp $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ \ $(foreach m,$(VALLEYAUDIO_CUSTOM),$(call custom_module_names,$(m),ValleyAudio)) \ $(foreach m,$(VALLEYAUDIO_CUSTOM_PER_FILE),$(call custom_per_file_names,$(m),ValleyAudio_$(shell basename $*))) \ - -DpluginInstance=pluginInstance__ValleyAudio + -DpluginInstance=pluginInstance__ValleyAudio \ + -DSTDIO_OVERRIDE=ValleyAudio $(BUILD_DIR)/ZetaCarinaeModules/%.cpp.o: ZetaCarinaeModules/%.cpp -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" diff --git a/plugins/todo.txt b/plugins/todo.txt index 4a9e020..f4d2e06 100644 --- a/plugins/todo.txt +++ b/plugins/todo.txt @@ -1,8 +1,5 @@ List of plugins still to add, sorted by popularity -- Working but limited: (v2 related limitations) -Befaco - - TODO, see list at https://github.com/VCVRack/library/tree/v1/repos Grayscale 74754.0 (not opensource?)