Browse Source

mingw cstdio workaround

Signed-off-by: falkTX <falktx@falktx.com>
tags/22.02
falkTX 3 years ago
parent
commit
239b6a1954
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 62 additions and 5 deletions
  1. +1
    -1
      dpf
  2. +59
    -0
      include/mingw-compat/cstdio
  3. +2
    -1
      plugins/Makefile
  4. +0
    -3
      plugins/todo.txt

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 1d756d6ac203d5c133769e1f5930f3dac7edb9bc
Subproject commit 6bf4d68dec211900a3f3e184678a904919e4aabc

+ 59
- 0
include/mingw-compat/cstdio View File

@@ -0,0 +1,59 @@
/*
* DISTRHO Cardinal Plugin
* Copyright (C) 2021 Filipe Coelho <falktx@falktx.com>
*
* 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 <cstdio> 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 <stdio.h> which will use our prefixed names
# include <stdio.h>

// step 3: undef and define dummy functions required for <cstdio> (it uses `using ::printf` syntax)
# undef printf
static inline void printf() {}

// step 4: we can safely include <cstdio> now
# include_next <cstdio>

// 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 <cstdio>

#endif // STDIO_OVERRIDE

+ 2
- 1
plugins/Makefile View File

@@ -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)/$<)"


+ 0
- 3
plugins/todo.txt View File

@@ -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?)


Loading…
Cancel
Save