From e39508e6f2bac8ae171b496bc3ece7eaa2e63114 Mon Sep 17 00:00:00 2001 From: Hannes Schulze Date: Fri, 7 Feb 2025 12:32:16 +0100 Subject: fix warnings --- lib/CMakeLists.txt | 1 + lib/nes/common/containers/box.hh | 1 - lib/nes/common/debug.hh | 4 ++++ lib/nes/common/utils.hh | 13 ++++++++++++- lib/nes/sys/cpu.hh | 3 ++- 5 files changed, 19 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 5dde4fd..3cf8a9b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -11,5 +11,6 @@ endif() if(NES_ENABLE_SNAPSHOTS) target_compile_definitions(nes PUBLIC NES_ENABLE_SNAPSHOTS) endif() +target_compile_definitions(nes PUBLIC NES_HAS_STDLIB) add_subdirectory(nes) \ No newline at end of file diff --git a/lib/nes/common/containers/box.hh b/lib/nes/common/containers/box.hh index 82f6448..b34958d 100644 --- a/lib/nes/common/containers/box.hh +++ b/lib/nes/common/containers/box.hh @@ -3,7 +3,6 @@ #include "nes/common/types.hh" #include "nes/common/debug.hh" #include "nes/common/utils.hh" -#include namespace nes { diff --git a/lib/nes/common/debug.hh b/lib/nes/common/debug.hh index 30370e9..a7a0854 100644 --- a/lib/nes/common/debug.hh +++ b/lib/nes/common/debug.hh @@ -21,7 +21,11 @@ #else +#ifdef NES_HAS_STDLIB #include +#else +#include "debug/assert.h" +#endif #define NES_ASSERT(...) \ assert(__VA_ARGS__) diff --git a/lib/nes/common/utils.hh b/lib/nes/common/utils.hh index 460d0d5..9a6194a 100644 --- a/lib/nes/common/utils.hh +++ b/lib/nes/common/utils.hh @@ -35,4 +35,15 @@ namespace nes a = b; b = tmp; } -} // namespace nes \ No newline at end of file +} // namespace nes + +#ifdef NES_HAS_STDLIB + +#include + +#else + +// Placement new is an API-defined operator for some reason!? +inline void* operator new(decltype(sizeof(int)), void* ptr) { return ptr; } + +#endif \ No newline at end of file diff --git a/lib/nes/sys/cpu.hh b/lib/nes/sys/cpu.hh index d9d0dd0..8c002ec 100644 --- a/lib/nes/sys/cpu.hh +++ b/lib/nes/sys/cpu.hh @@ -293,7 +293,8 @@ namespace nes::sys #define DEFINE_CYCLE_COUNT(name) \ template static auto name##_cycle_count() -> cycle_count; #define DEFINE_CYCLE_COUNT_INSTANCE(name, mode, value) \ - template<> auto name##_cycle_count() -> cycle_count { return cycle_count::from_cpu(value); } + template<> \ + [[maybe_unused]] auto name##_cycle_count() -> cycle_count { return cycle_count::from_cpu(value); } DEFINE_CYCLE_COUNT(jump) DEFINE_CYCLE_COUNT_INSTANCE(jump, absolute, 3) -- cgit v1.3.1