Skip to content

Commit

Permalink
Cpp20 upgrade (#103)
Browse files Browse the repository at this point in the history
Upgrade to c++20, fix c++20 compilation errors related to use of char vs const char. Changed config parsing to rely at least partially on c++ string instead of C char/str functions.
  • Loading branch information
petschau authored Oct 15, 2023
1 parent 59051d5 commit 7a55eac
Show file tree
Hide file tree
Showing 70 changed files with 6,750 additions and 6,673 deletions.
12 changes: 6 additions & 6 deletions fellow/SRC/WinFellow.Core.Tests/WinFellow.Core.Tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<AdditionalIncludeDirectories>../WinFellow.Core;../WinFellow.Test.Infrastructure</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
<BufferSecurityCheck>false</BufferSecurityCheck>
Expand All @@ -145,7 +145,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<AdditionalIncludeDirectories>../WinFellow.Core;../WinFellow.Test.Infrastructure</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
Expand All @@ -171,7 +171,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<AdditionalIncludeDirectories>../WinFellow.Core;../WinFellow.Test.Infrastructure</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
<BufferSecurityCheck>false</BufferSecurityCheck>
Expand All @@ -192,7 +192,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<AdditionalIncludeDirectories>../WinFellow.Core;../WinFellow.Test.Infrastructure</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
<BufferSecurityCheck>false</BufferSecurityCheck>
Expand All @@ -215,7 +215,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<AdditionalIncludeDirectories>../WinFellow.Core;../WinFellow.Test.Infrastructure</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
Expand Down Expand Up @@ -243,7 +243,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<AdditionalIncludeDirectories>../WinFellow.Core;../WinFellow.Test.Infrastructure</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
Expand Down
34 changes: 16 additions & 18 deletions fellow/SRC/WinFellow.Core/CustomChipset/Sound/Sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,20 @@
#include "CustomChipset/Sound/SoundConfiguration.h"
#include "WavFileWriter.h"

using namespace CustomChipset;

constexpr uint32_t MAX_BUFFER_SAMPLES = 65536;

class Sound
{
private:
WavFileWriter _wavFileWriter;

sound_emulations _emulation;
sound_rates _rate;
CustomChipset::sound_emulations _emulation;
CustomChipset::sound_rates _rate;
bool _isStereo;
bool _is16Bits;
bool _wavCapture;
sound_filters _filter;
sound_notifications _notification;
CustomChipset::sound_filters _filter;
CustomChipset::sound_notifications _notification;
int _volume;
bool _deviceFound;

Expand Down Expand Up @@ -106,8 +104,8 @@ class Sound

uint32_t _periodTable[65536];
int16_t _volumes[256][64];
uint32_t _audioIrqMask[4] = {0x0080, 0x0100, 0x0200, 0x0400};
uint32_t _audioDmaconMask[4] = {0x1, 0x2, 0x4, 0x8};
uint32_t _audioIrqMask[4] = { 0x0080, 0x0100, 0x0200, 0x0400 };
uint32_t _audioDmaconMask[4] = { 0x1, 0x2, 0x4, 0x8 };

uint32_t GetChannelNumber(uint32_t address);

Expand All @@ -120,11 +118,11 @@ class Sound
void State5(uint32_t channel);
void State6(uint32_t channel);

void LowPass(uint32_t count, int16_t *bufferLeft, int16_t *bufferRight);
uint32_t ChannelUpdate(uint32_t channel, int16_t *bufferLeft, int16_t *bufferRight, uint32_t count, bool halfscale, bool odd);
void LowPass(uint32_t count, int16_t* bufferLeft, int16_t* bufferRight);
uint32_t ChannelUpdate(uint32_t channel, int16_t* bufferLeft, int16_t* bufferRight, uint32_t count, bool halfscale, bool odd);
void FrequencyHandler();

sound_rates GetRate();
CustomChipset::sound_rates GetRate();
uint32_t GetRateReal();
uint32_t GetBufferLength();
int GetVolume();
Expand Down Expand Up @@ -152,19 +150,19 @@ class Sound
void CopyBufferOverrunToCurrentBuffer(uint32_t availableSamples, uint32_t previousBuffer);

public:
void SetEmulation(sound_emulations emulation);
sound_emulations GetEmulation();
void SetEmulation(CustomChipset::sound_emulations emulation);
CustomChipset::sound_emulations GetEmulation();
void SetIsStereo(bool isStereo);
bool GetIsStereo();
void SetIs16Bits(bool is16Bits);
bool GetIs16Bits();
void SetFilter(sound_filters filter);
sound_filters GetFilter();
void SetFilter(CustomChipset::sound_filters filter);
CustomChipset::sound_filters GetFilter();
void SetWAVDump(bool wavCapture);
bool GetWAVDump();
void SetNotification(sound_notifications notification);
sound_notifications GetNotification();
void SetRate(sound_rates rate);
void SetNotification(CustomChipset::sound_notifications notification);
CustomChipset::sound_notifications GetNotification();
void SetRate(CustomChipset::sound_rates rate);
void SetBufferLength(uint32_t ms);

void ChannelKill(uint32_t channel);
Expand Down
2 changes: 1 addition & 1 deletion fellow/SRC/WinFellow.Core/Service/ILog.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Service
virtual void AddLogDebug(const char* format, ...) = 0;
virtual void AddLog(const char*, ...) = 0;
virtual void AddLogList(const std::list<std::string>& messages) = 0;
virtual void AddLog2(char* msg) = 0;
virtual void AddLog2(const char* msg) = 0;
virtual void AddTimelessLog(const char* format, ...) = 0;

ILog() = default;
Expand Down
4 changes: 2 additions & 2 deletions fellow/SRC/WinFellow.Core/Service/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace Service
CloseLogFile(F);
}

void Log::AddLog2(char* msg)
void Log::AddLog2(const char* msg)
{
if (!_enabled)
{
Expand All @@ -118,7 +118,7 @@ namespace Service
AddLog2(buffer);
}

void Log::AddLogInternal(FILE* F, char* msg)
void Log::AddLogInternal(FILE* F, const char* msg)
{
fprintf(F, "%s", msg);
_new_line = (msg[strlen(msg) - 1] == '\n');
Expand Down
4 changes: 2 additions & 2 deletions fellow/SRC/WinFellow.Core/Service/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace Service
char* LogTime(char* buffer);
FILE* OpenLogFile();
void CloseLogFile(FILE* F);
void AddLogInternal(FILE* F, char* msg);
void AddLogInternal(FILE* F, const char* msg);

public:
void AddLogDebug(const char* format, ...) override;
void AddLog(const char*, ...) override;
void AddLogList(const std::list<std::string>& messages) override;
void AddLog2(char* msg) override;
void AddLog2(const char* msg) override;
void AddTimelessLog(const char* format, ...) override;

Log();
Expand Down
24 changes: 12 additions & 12 deletions fellow/SRC/WinFellow.Core/WinFellow.Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
Expand All @@ -163,7 +163,7 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
Expand All @@ -180,12 +180,12 @@
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
Expand All @@ -209,7 +209,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
Expand All @@ -221,7 +221,7 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
Expand All @@ -236,7 +236,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
Expand All @@ -248,7 +248,7 @@
<BufferSecurityCheck>false</BufferSecurityCheck>
<FloatingPointModel>Fast</FloatingPointModel>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
Expand All @@ -267,12 +267,12 @@
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
Expand All @@ -298,12 +298,12 @@
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
Expand Down
Loading

0 comments on commit 7a55eac

Please sign in to comment.