diff --git a/Changes.txt b/Changes.txt index ec3e29084..a89b30d1a 100644 --- a/Changes.txt +++ b/Changes.txt @@ -34,7 +34,7 @@ * Added Joy2B+ controller support. - * Added auto detection for QuadTari attached controllers + * Added auto detection for QuadTari attached controllers. * Enhanced Kid Vid support to play tape audio. @@ -42,7 +42,7 @@ * Added missing PlusROM support for E7 bankswitching. - * Enhanced movie cart (MVC) support + * Enhanced movie cart (MVC) support. * Accelerated emulation up to ~15% (ARM). @@ -60,6 +60,9 @@ * Removed 'launcherroms' option, since it was causing some issues. + * Codebase now uses C++20 features, which means a minimum of gcc-11 + or clang-10 for Linux/Mac, and Visual Studio 2022 for Windows. + -Have fun! diff --git a/Makefile b/Makefile index 1ab4da8cd..8d438dcfe 100644 --- a/Makefile +++ b/Makefile @@ -51,12 +51,12 @@ CXXFLAGS+= -Wall -Wextra -Wno-unused-parameter CFLAGS+= -Wall -Wextra -Wno-unused-parameter ifdef HAVE_GCC - CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17 + CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++20 CFLAGS+= -Wno-multichar -Wunused endif ifdef HAVE_CLANG - CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++17 + CXXFLAGS+= -Wno-multichar -Wunused -Woverloaded-virtual -Wnon-virtual-dtor -std=c++20 CFLAGS+= -Wno-multichar -Wunused endif diff --git a/configure b/configure index d7861ac60..3d36c7105 100755 --- a/configure +++ b/configure @@ -378,7 +378,7 @@ else fi for compiler in $compilers; do - if test_compiler "$compiler -std=c++17"; then + if test_compiler "$compiler -std=c++20"; then CXX=$compiler echo $CXX break diff --git a/docs/index.html b/docs/index.html index f6aed096b..d622d899e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -265,7 +265,7 @@

Features

diff --git a/src/common/FSNodeFactory.hxx b/src/common/FSNodeFactory.hxx index 1a342a6e0..b49048e9a 100644 --- a/src/common/FSNodeFactory.hxx +++ b/src/common/FSNodeFactory.hxx @@ -62,8 +62,9 @@ class FSNodeFactory return make_unique(path); #endif break; + default: + return nullptr; } - return nullptr; } private: diff --git a/src/common/FSNodeZIP.cxx b/src/common/FSNodeZIP.cxx index 1bdd54d0f..cc958e9b1 100644 --- a/src/common/FSNodeZIP.cxx +++ b/src/common/FSNodeZIP.cxx @@ -218,6 +218,7 @@ size_t FSNodeZIP::read(ByteBuffer& buffer, size_t) const case zip_error::NOT_A_FILE: throw runtime_error("ZIP file contains errors/not found"); case zip_error::NOT_READABLE: throw runtime_error("ZIP file not readable"); case zip_error::NO_ROMS: throw runtime_error("ZIP file doesn't contain any ROMs"); + default: throw runtime_error("FSNodeZIP::read default case hit"); } myZipHandler->open(_zipFile); diff --git a/src/common/FpsMeter.cxx b/src/common/FpsMeter.cxx index fa1738f19..db32cd30a 100644 --- a/src/common/FpsMeter.cxx +++ b/src/common/FpsMeter.cxx @@ -46,32 +46,27 @@ void FpsMeter::render(uInt32 frameCount) } const size_t queueSize = myQueue.capacity(); - entry first, last; + entry e_first, e_last; - last.frames = frameCount; - last.timestamp = high_resolution_clock::now(); + e_last.frames = frameCount; + e_last.timestamp = high_resolution_clock::now(); if (myQueue.size() < queueSize) { - myQueue.push_back(last); + myQueue.push_back(e_last); myFrameCount += frameCount; - first = myQueue.at(myQueueOffset); + e_first = myQueue.at(myQueueOffset); } else { myFrameCount = myFrameCount - myQueue.at(myQueueOffset).frames + frameCount; - myQueue.at(myQueueOffset) = last; + myQueue.at(myQueueOffset) = e_last; myQueueOffset = (myQueueOffset + 1) % queueSize; - first = myQueue.at(myQueueOffset); + e_first = myQueue.at(myQueueOffset); } const float myTimeInterval = - duration_cast>(last.timestamp - first.timestamp).count(); + duration_cast>(e_last.timestamp - e_first.timestamp).count(); - if (myTimeInterval > 0) myFps = (myFrameCount - first.frames) / myTimeInterval; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -float FpsMeter::fps() const -{ - return myFps; + if (myTimeInterval > 0) + myFps = (myFrameCount - e_first.frames) / myTimeInterval; } diff --git a/src/common/FpsMeter.hxx b/src/common/FpsMeter.hxx index c259ea579..ba6a73526 100644 --- a/src/common/FpsMeter.hxx +++ b/src/common/FpsMeter.hxx @@ -32,7 +32,7 @@ class FpsMeter void render(uInt32 frameCount); - float fps() const; + float fps() const { return myFps; } private: diff --git a/src/common/LinkedObjectPool.hxx b/src/common/LinkedObjectPool.hxx index 167ce78c2..6bd81b3ed 100644 --- a/src/common/LinkedObjectPool.hxx +++ b/src/common/LinkedObjectPool.hxx @@ -59,7 +59,7 @@ class LinkedObjectPool /* Create a pool of size CAPACITY; the active list starts out empty. */ - LinkedObjectPool() { resize(CAPACITY); } + LinkedObjectPool() { resize(CAPACITY); } /** Return node data that the 'current' iterator points to. diff --git a/src/common/MouseControl.cxx b/src/common/MouseControl.cxx index b74b7f9e2..0ece4d5aa 100644 --- a/src/common/MouseControl.cxx +++ b/src/common/MouseControl.cxx @@ -96,6 +96,8 @@ MouseControl::MouseControl(Console& console, string_view mode) id = 1; msg << "Right MindLink"; break; + default: + break; // Not supposed to get here } }; diff --git a/src/common/SDL_lib.hxx b/src/common/SDL_lib.hxx index 68ed1f267..c0675988b 100644 --- a/src/common/SDL_lib.hxx +++ b/src/common/SDL_lib.hxx @@ -31,6 +31,7 @@ #pragma clang diagnostic ignored "-Wimplicit-fallthrough" #pragma clang diagnostic ignored "-Wreserved-id-macro" #pragma clang diagnostic ignored "-Wold-style-cast" + #pragma clang diagnostic ignored "-Wswitch-default" #include #pragma clang diagnostic pop #elif defined(BSPF_WINDOWS) diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index c16905e50..4061fafcf 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -283,6 +283,8 @@ string SoundSDL2::about() const case AudioSettings::Preset::ultraQualityMinimalLag: buf << "Ultra quality, minimal lag\n"; break; + default: + break; // Not supposed to get here } buf << " Fragment size: " << static_cast(myHardwareSpec.samples) << " bytes\n" @@ -300,6 +302,8 @@ string SoundSDL2::about() const case AudioSettings::ResamplingQuality::lanczos_3: buf << "Quality 3, Lanczos (a = 3)\n"; break; + default: + break; // Not supposed to get here } buf << " Headroom: " << std::fixed << std::setprecision(1) << (0.5 * myAudioSettings.headroom()) << " frames\n" diff --git a/src/common/Stack.hxx b/src/common/Stack.hxx index d1ad8efd2..88e59acf6 100644 --- a/src/common/Stack.hxx +++ b/src/common/Stack.hxx @@ -37,7 +37,7 @@ class FixedStack public: using StackFunction = std::function; - FixedStack() = default; + FixedStack() = default; bool empty() const { return _size == 0; } bool full() const { return _size >= CAPACITY; } diff --git a/src/common/VideoModeHandler.cxx b/src/common/VideoModeHandler.cxx index 0e4d7d1a1..172588980 100644 --- a/src/common/VideoModeHandler.cxx +++ b/src/common/VideoModeHandler.cxx @@ -139,6 +139,8 @@ VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, iw = std::min(static_cast(iw * zoomLevel), screenS.w) * overscan; ih = std::min(static_cast(ih * zoomLevel), screenS.h) * overscan; break; + default: + break; // Not supposed to get here } } else @@ -157,6 +159,9 @@ VideoModeHandler::Mode::Mode(uInt32 iw, uInt32 ih, uInt32 sw, uInt32 sh, case Stretch::None: // UI Mode break; // Do not change image or screen rects whatsoever + + default: + break; // Not supposed to get here } } diff --git a/src/common/tv_filters/AtariNTSC.cxx b/src/common/tv_filters/AtariNTSC.cxx index 6631451e6..368fafd6c 100644 --- a/src/common/tv_filters/AtariNTSC.cxx +++ b/src/common/tv_filters/AtariNTSC.cxx @@ -107,7 +107,7 @@ void AtariNTSC::render(const uInt8* atari_in, const uInt32 in_width, // Spawn the threads... for(uInt32 i = 0; i < myWorkerThreads; ++i) { - myThreads[i] = std::thread([=] // NOLINT (cppcoreguidelines-misleading-capture-default-by-value + myThreads[i] = std::thread([=, this] { rgb_in == nullptr ? renderThread(atari_in, in_width, in_height, myTotalThreads, diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 6985ebd8e..e7714d89b 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -741,6 +741,9 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead, } break; } + + default: + break; // Not supposed to get here } switch(places) diff --git a/src/debugger/DebuggerParser.cxx b/src/debugger/DebuggerParser.cxx index ed2fae1d8..71e3e623b 100644 --- a/src/debugger/DebuggerParser.cxx +++ b/src/debugger/DebuggerParser.cxx @@ -383,6 +383,8 @@ bool DebuggerParser::getArgs(string_view command, string& verb) curArg += c; } break; + default: + break; // Not supposed to get here } // switch(state) } while(i < length); @@ -505,6 +507,9 @@ bool DebuggerParser::validateArgs(int cmd) case Parameters::ARG_END_ARGS: break; + + default: + break; // Not supposed to get here } ++curCount; ++p; @@ -2645,6 +2650,8 @@ void DebuggerParser::executeTrapRW(uInt32 addr, bool read, bool write, bool add) } break; } + default: + break; // Not supposed to get here } } diff --git a/src/debugger/TIADebug.cxx b/src/debugger/TIADebug.cxx index 81d8f9732..a1aa740d8 100644 --- a/src/debugger/TIADebug.cxx +++ b/src/debugger/TIADebug.cxx @@ -505,8 +505,10 @@ bool TIADebug::collision(CollisionBit id, bool toggle) const if(toggle) myTIA.toggleCollM0M1(); return myTIA.collCXPPMM() & 0x40; + + default: + return false; // Not supposed to get here } - return false; // make compiler happy } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/yacc/YaccParser.cxx b/src/debugger/yacc/YaccParser.cxx index a15f4fcd3..eeb2e11c5 100644 --- a/src/debugger/yacc/YaccParser.cxx +++ b/src/debugger/yacc/YaccParser.cxx @@ -399,6 +399,9 @@ int yylex() { return yylval.val; } break; + + default: + break; // Not supposed to get here } } diff --git a/src/emucore/CartMVC.cxx b/src/emucore/CartMVC.cxx index ac51e4468..55c91bc2f 100755 --- a/src/emucore/CartMVC.cxx +++ b/src/emucore/CartMVC.cxx @@ -1516,6 +1516,9 @@ bool MovieCart::process(uInt16 address) case TitleState::Stream: runStateMachine(); break; + + default: + break; // Not supposed to get here } return a12; diff --git a/src/emucore/FBSurface.cxx b/src/emucore/FBSurface.cxx index 611ef5016..c167ad502 100644 --- a/src/emucore/FBSurface.cxx +++ b/src/emucore/FBSurface.cxx @@ -293,6 +293,9 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, vLine(x + w - 1, i, i, color); } break; + + default: + break; // Not supposed to get here } } diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index ce44e5b2d..b3f6ab99c 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -104,7 +104,7 @@ class FSNode /** * Append the given path to the node, adding a directory separator - * when necessary. Modelled on the C++17 fs::path API. + * when necessary. */ FSNode& operator/=(string_view path); diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index ed86f1065..f6b80e353 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -890,6 +890,9 @@ inline bool FrameBuffer::drawMessage() myMsg.x = imageRect().w() - dst.w() - 5; myMsg.y = imageRect().h() - dst.h() - 5; break; + + default: + break; // Not supposed to get here } myMsg.surface->setDstPos(myMsg.x + imageRect().x(), myMsg.y + imageRect().y()); diff --git a/src/emucore/PlusROM.cxx b/src/emucore/PlusROM.cxx index f5c78c5e6..3680d2c87 100644 --- a/src/emucore/PlusROM.cxx +++ b/src/emucore/PlusROM.cxx @@ -433,7 +433,7 @@ void PlusROM::send() // as the thread is running. Thus, the request can only be destructed once // the thread has finished, and we can safely evict it from the deque at // any time. - std::thread thread([=]() // NOLINT (cppcoreguidelines-misleading-capture-default-by-value) + std::thread thread([=, this]() { request->execute(); switch(request->getState()) diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index 438644ff3..fcab48c53 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -482,6 +482,8 @@ string TIASurface::effectsInfo() const case Filter::BlarggPhosphor: buf << myNTSCFilter.getPreset() << ", phosphor=" << myPBlend; break; + default: + break; // Not supposed to get here } if(attr.blendalpha) buf << ", scanlines=" << attr.blendalpha @@ -585,6 +587,9 @@ void TIASurface::render(bool shade) myNTSCFilter.render(myTIA->frameBuffer(), width, height, out, outPitch << 2, myRGBFramebuffer.data()); break; } + + default: + break; // Not supposed to get here } // Draw TIA image @@ -624,7 +629,7 @@ void TIASurface::renderForSnapshot() myTiaSurface->basePtr(outPtr, outPitch); mySaveSnapFlag = false; - switch (myFilter) + switch(myFilter) { // For non-phosphor modes, render the frame again case Filter::Normal: @@ -650,11 +655,16 @@ void TIASurface::renderForSnapshot() } case Filter::BlarggPhosphor: + { uInt32 bufofs = 0; for(uInt32 y = height; y; --y) for(uInt32 x = outPitch; x; --x) outPtr[pos++] = averageBuffers(bufofs++); break; + } + + default: + break; // Not supposed to get here } if(myPhosphorHandler.phosphorEnabled()) diff --git a/src/emucore/tia/Playfield.cxx b/src/emucore/tia/Playfield.cxx index 4c90a3e54..d7ccad8bd 100644 --- a/src/emucore/tia/Playfield.cxx +++ b/src/emucore/tia/Playfield.cxx @@ -224,6 +224,9 @@ void Playfield::applyColors() myColorRight = myColorP1 &= 0xfe; } break; + + default: + break; // Not supposed to get here } } } diff --git a/src/emucore/tia/TIA.cxx b/src/emucore/tia/TIA.cxx index 81185c8f8..9648fb161 100644 --- a/src/emucore/tia/TIA.cxx +++ b/src/emucore/tia/TIA.cxx @@ -436,6 +436,9 @@ void TIA::bindToControllers() case Controller::AnalogPin::Nine: updateAnalogReadout(0); break; + + default: + break; // Not supposed to get here } } ); @@ -452,6 +455,9 @@ void TIA::bindToControllers() case Controller::AnalogPin::Nine: updateAnalogReadout(2); break; + + default: + break; // Not supposed to get here } } ); @@ -1797,6 +1803,9 @@ FORCE_INLINE void TIA::renderPixel(uInt32 x, uInt32 y) else if (myBall.isOn()) color = myBall.getColor(); else color = myBackground.getColor(); break; + + default: + break; // Not supposed to get here } } diff --git a/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx b/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx index 504d8f3a3..1fe79f651 100644 --- a/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx +++ b/src/emucore/tia/frame-manager/FrameLayoutDetector.cxx @@ -239,7 +239,7 @@ void FrameLayoutDetector::finalizeFrame() // 1.0 (>=312) and added to PAL and (inverted) NTSC sums. constexpr double ODD_PENALTY = 0.5; // guessed value :) const double palFrame = BSPF::clamp(((myCurrentFrameFinalLines % 2) ? ODD_PENALTY : 1.0) - * (static_cast(myCurrentFrameFinalLines) - frameLinesNTSC) + * static_cast(myCurrentFrameFinalLines - frameLinesNTSC) / static_cast(frameLinesPAL - frameLinesNTSC), 0.0, 1.0); myPalFrameSum += palFrame; myNtscFrameSum += 1.0 - palFrame; diff --git a/src/gui/BrowserDialog.cxx b/src/gui/BrowserDialog.cxx index 26719b0ba..1de98b0a3 100644 --- a/src/gui/BrowserDialog.cxx +++ b/src/gui/BrowserDialog.cxx @@ -265,6 +265,9 @@ void BrowserDialog::show(string_view startpath, _selected->setEnabled(false); _okWidget->setLabel("OK"); break; + + default: + break; // Not supposed to get here } // Set start path diff --git a/src/gui/DialogContainer.cxx b/src/gui/DialogContainer.cxx index ea28d6b4e..752b598b0 100644 --- a/src/gui/DialogContainer.cxx +++ b/src/gui/DialogContainer.cxx @@ -320,6 +320,7 @@ void DialogContainer::handleMouseButtonEvent(MouseButton b, bool pressed, break; case MouseButton::NONE: // should never get here + default: break; } } diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index c397172be..3a85b38b7 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -968,6 +968,8 @@ void CheckboxWidget::setFill(FillType type) _img = checked_img_circle.data(); _drawBox = false; break; + default: + break; // Not supposed to get here } setDirty(); } diff --git a/src/os/libretro/Makefile b/src/os/libretro/Makefile index d8695faef..444d0507e 100644 --- a/src/os/libretro/Makefile +++ b/src/os/libretro/Makefile @@ -46,7 +46,7 @@ TARGET_NAME = stella ifeq (,$(findstring msvc,$(platform))) - CXXFLAGS += -std=c++17 -fno-rtti + CXXFLAGS += -std=c++20 -fno-rtti LIBS := -lm else LIBS := @@ -305,8 +305,8 @@ else ifneq (,$(filter $(platform), ngc wii wiiu)) else ifeq ($(platform), emscripten) TARGET := $(TARGET_NAME)_libretro_$(platform).bc STATIC_LINKING = 1 - CXXFLAGS += $(PTHREAD_FLAGS) -std=c++17 - LDFLAGS += $(PTHREAD_FLAGS) -std=c++17 + CXXFLAGS += $(PTHREAD_FLAGS) -std=c++20 + LDFLAGS += $(PTHREAD_FLAGS) -std=c++20 # Genode else ifeq ($(platform), genode) @@ -370,7 +370,7 @@ else ifneq (,$(findstring windows_msvc2017,$(platform))) endif # Specific to this core - MSVC2017CompileFlags += -D__WIN32__ /std:c++17 + MSVC2017CompileFlags += -D__WIN32__ /std:c++20 CXX = cl.exe CXXFLAGS += $(MSVC2017CompileFlags) diff --git a/src/os/libretro/jni/Android.mk b/src/os/libretro/jni/Android.mk index b420f3fc4..5297ad372 100644 --- a/src/os/libretro/jni/Android.mk +++ b/src/os/libretro/jni/Android.mk @@ -14,6 +14,6 @@ endif include $(CLEAR_VARS) LOCAL_MODULE := retro LOCAL_SRC_FILES := $(SOURCES_CXX) $(SOURCES_C) -LOCAL_CXXFLAGS := $(COREFLAGS) -std=c++17 +LOCAL_CXXFLAGS := $(COREFLAGS) -std=c++20 LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/os/libretro/link.T include $(BUILD_SHARED_LIBRARY) diff --git a/src/os/macos/stella.xcodeproj/project.pbxproj b/src/os/macos/stella.xcodeproj/project.pbxproj index 2b85aaacb..f343f8aa0 100644 --- a/src/os/macos/stella.xcodeproj/project.pbxproj +++ b/src/os/macos/stella.xcodeproj/project.pbxproj @@ -3791,7 +3791,7 @@ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; - CLANG_CXX_LANGUAGE_STANDARD = "c++17"; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ATOMIC_IMPLICIT_SEQ_CST = YES; @@ -3869,7 +3869,7 @@ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; - CLANG_CXX_LANGUAGE_STANDARD = "c++17"; + CLANG_CXX_LANGUAGE_STANDARD = "c++20"; CLANG_CXX_LIBRARY = "libc++"; CLANG_WARN_ASSIGN_ENUM = YES; CLANG_WARN_ATOMIC_IMPLICIT_SEQ_CST = YES; diff --git a/src/os/windows/Stella.vcxproj b/src/os/windows/Stella.vcxproj index 59791d566..7070f30c2 100755 --- a/src/os/windows/Stella.vcxproj +++ b/src/os/windows/Stella.vcxproj @@ -593,7 +593,7 @@ Level4 None $(IntDir)obj\\windows\%(RelativeDir) - stdcpp17 + stdcpp20 true 4100;4127;4146;4244;26400;26409;26410;26415;26429;26438;26440;26446;26451;26455;26459;26467;26472;26481;26482;26485;26492;%(DisableSpecificWarnings) CompileAsCpp