Skip to content

Commit

Permalink
Fix C++98 compat
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Sep 29, 2024
1 parent 5b7fe8d commit f29c4d1
Show file tree
Hide file tree
Showing 9 changed files with 381 additions and 227 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ jobs:
CXXFLAGS: -Werror
run: |
xvfb-run make -C tests run
# FIXME enable again after finishing web-ui stuff
# - name: As C++98 mode
# env:
# CFLAGS: -Werror
# CXXFLAGS: -Werror -std=gnu++98
# run: |
# make clean >/dev/null
# make -j $(nproc)
- name: As C++98 mode
env:
CFLAGS: -Werror
CXXFLAGS: -Werror -std=gnu++98
run: |
make clean >/dev/null
make -j $(nproc)
- name: No namespace
env:
CFLAGS: -Werror
Expand Down
4 changes: 4 additions & 0 deletions distrho/DistrhoUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@

#include "src/DistrhoDefines.h"

#ifndef __STDC_LIMIT_MACROS
# define __STDC_LIMIT_MACROS
#endif

#include <cstdarg>
#include <cstdio>
#include <cstdlib>
Expand Down
30 changes: 24 additions & 6 deletions distrho/extra/ChildProcess.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// SPDX-FileCopyrightText: 2023-2024 MOD Audio UG
// SPDX-License-Identifier: AGPL-3.0-or-later
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
* permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#pragma once

Expand All @@ -24,13 +37,18 @@ START_NAMESPACE_DISTRHO
class ChildProcess
{
#ifdef _WIN32
PROCESS_INFORMATION pinfo = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0, 0 };
PROCESS_INFORMATION pinfo;
#else
pid_t pid = -1;
pid_t pid;
#endif

public:
ChildProcess()
#ifdef _WIN32
: pinfo((PROCESS_INFORMATION){ INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0, 0 })
#else
: pid(-1)
#endif
{
}

Expand Down Expand Up @@ -120,7 +138,7 @@ class ChildProcess
return;

const PROCESS_INFORMATION opinfo = pinfo;
pinfo = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0, 0 };
pinfo = (PROCESS_INFORMATION){ INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0, 0 };

for (DWORD exitCode;;)
{
Expand Down Expand Up @@ -226,7 +244,7 @@ class ChildProcess
WaitForSingleObject(pinfo.hProcess, 0) != WAIT_TIMEOUT)
{
const PROCESS_INFORMATION opinfo = pinfo;
pinfo = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0, 0 };
pinfo = (PROCESS_INFORMATION){ INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, 0, 0 };
CloseHandle(opinfo.hThread);
CloseHandle(opinfo.hProcess);
return false;
Expand Down
6 changes: 3 additions & 3 deletions distrho/extra/ExternalWindow.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
Expand Down Expand Up @@ -78,13 +78,13 @@ class ExternalWindow
Constructor.
*/
explicit ExternalWindow()
: pData() {}
: pData() {}

/**
Constructor for DPF internal use.
*/
explicit ExternalWindow(const PrivateData& data)
: pData(data) {}
: pData(data) {}

/**
Destructor.
Expand Down
25 changes: 3 additions & 22 deletions distrho/extra/RingBuffer.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with
* or without fee is hereby granted, provided that the above copyright notice and this
Expand Down Expand Up @@ -119,14 +119,6 @@ struct HugeStackBuffer {
uint8_t buf[size];
};

#ifdef DISTRHO_PROPER_CPP11_SUPPORT
# define HeapBuffer_INIT {0, 0, 0, 0, false, nullptr}
# define StackBuffer_INIT {0, 0, 0, false, {0}}
#else
# define HeapBuffer_INIT
# define StackBuffer_INIT
#endif

// -----------------------------------------------------------------------
// RingBufferControl templated class

Expand Down Expand Up @@ -799,12 +791,7 @@ class HeapRingBuffer : public RingBufferControl<HeapBuffer>
public:
/** Constructor. */
HeapRingBuffer() noexcept
: heapBuffer(HeapBuffer_INIT)
{
#ifndef DISTRHO_PROPER_CPP11_SUPPORT
std::memset(&heapBuffer, 0, sizeof(heapBuffer));
#endif
}
: heapBuffer((HeapBuffer){0, 0, 0, 0, false, nullptr}) {}

/** Destructor. */
~HeapRingBuffer() noexcept override
Expand Down Expand Up @@ -874,13 +861,7 @@ class SmallStackRingBuffer : public RingBufferControl<SmallStackBuffer>
public:
/** Constructor. */
SmallStackRingBuffer() noexcept
: stackBuffer(StackBuffer_INIT)
{
#ifndef DISTRHO_PROPER_CPP11_SUPPORT
std::memset(&stackBuffer, 0, sizeof(stackBuffer));
#endif
setRingBuffer(&stackBuffer, true);
}
: stackBuffer((SmallStackBuffer){0, 0, 0, false, {0}}) {}

private:
/** The small stack buffer used for this class. */
Expand Down
Loading

0 comments on commit f29c4d1

Please sign in to comment.