From 0a78316bcead4984baa98b6d2bf5fe035ba49d87 Mon Sep 17 00:00:00 2001 From: Attila Uygun Date: Sat, 12 Aug 2023 21:22:54 +0200 Subject: [PATCH] warnings --- build/BUILD.gn | 53 +++++++++++++++++------------- src/engine/asset/image.cc | 5 --- src/engine/asset/sound.cc | 3 -- src/third_party/BUILD.gn | 5 ++- src/third_party/minimp3/minimp3.cc | 6 ++++ src/third_party/stb/stb_image.cc | 10 ++++++ 6 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 src/third_party/minimp3/minimp3.cc create mode 100644 src/third_party/stb/stb_image.cc diff --git a/build/BUILD.gn b/build/BUILD.gn index 4700b6b..a3cd72c 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -164,6 +164,14 @@ config("release") { } } +config("third_party_warnings") { + if (is_win) { + cflags = [ + "/wd4242", # tmp:conversion from 'int' to 'uint8_t' + ] + } +} + config("warnings") { if (is_win) { cflags = [ @@ -187,51 +195,50 @@ config("warnings") { # switch specified. # TODO: Not sure how I feel about these conversion warnings. - "/Wv:18", # tmp - "/wd4191", # tmp:'type cast': unsafe conversion - "/wd4242", # tmp:conversion from 'int' to 'uint8_t' - "/wd4245", # tmp:conversion from 'int' to 'const unsigned int' + "/Wv:18", + "/wd4191", # 'type cast': unsafe conversion "/wd4244", # conversion, possible loss of data. 'int' to 'float' - "/wd4267", # conversion, possible loss of data. + "/wd4245", # tmp:conversion from 'int' to 'const unsigned int' + # "/wd4267", # conversion, possible loss of data. "/wd4305", # truncation from 'double' to 'float'. "/wd4365", # conversion, signed/unsigned mismatch. - "/wd5219", # conversion, possible loss of data. 'int' to 'float' + # "/wd5219", # conversion, possible loss of data. 'int' to 'float' # Possible compiler bug? Needs investigation. "/wd4668", # '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor # macro, replacing with '0' for '#if/#elif' # TODO: - "/wd4263", # member function does not override any base class virtual + # "/wd4263", # member function does not override any base class virtual # member function - "/wd4264", # no override available for virtual member function, function + # "/wd4264", # no override available for virtual member function, function # is hidden - "/wd4266", # no override available for virtual member function from base, + # "/wd4266", # no override available for virtual member function from base, # function is hidden - "/wd4355", # 'this' used in base member initializer list - "/wd4457", # declaration hides function parameter - "/wd4464", # relative include path contains '..'. + # "/wd4355", # 'this' used in base member initializer list + # "/wd4457", # declaration hides function parameter + # "/wd4464", # relative include path contains '..'. "/wd4625", # copy constructor was implicitly defined as deleted "/wd4626", # assignment operator was implicitly defined as deleted - "/wd4706", # assignment withing conditional expression. - "/wd4774", # format string expected in argument X is not a string literal - "/wd4828", # The file contains a character that is illegal in the current + # "/wd4706", # assignment withing conditional expression. + # "/wd4774", # format string expected in argument X is not a string literal + # "/wd4828", # The file contains a character that is illegal in the current # source character set - "/wd4946", # reinterpret_cast used between related - "/wd5026", # move constructor was implicitly defined as deleted - "/wd5027", # move assignment operator was implicitly defined as deleted - "/wd5039", # pointer or reference to potentially throwing function passed + # "/wd4946", # reinterpret_cast used between related + # "/wd5026", # move constructor was implicitly defined as deleted + # "/wd5027", # move assignment operator was implicitly defined as deleted + # "/wd5039", # pointer or reference to potentially throwing function passed # to 'extern "C"' function under -EHc. Undefined behavior may # occur if this function throws an exception. # TODO: I don't understand these or how to fix them: - "/wd4458", # declaration hides class member + # "/wd4458", # declaration hides class member # [ GameObject::rtti ] - "/wd4582", # constructor is not implicitly called + # "/wd4582", # constructor is not implicitly called # [ intersection.h Contact ] - "/wd4623", # default constructor was implicitly defined as deleted + # "/wd4623", # default constructor was implicitly defined as deleted # [ intersection.h Contact ] - "/wd5243", # using incomplete class can cause potential one definition + # "/wd5243", # using incomplete class can cause potential one definition # rule violation due to ABI limitation ] diff --git a/src/engine/asset/image.cc b/src/engine/asset/image.cc index dcf7f94..ae289e5 100644 --- a/src/engine/asset/image.cc +++ b/src/engine/asset/image.cc @@ -12,12 +12,7 @@ #include "third_party/texture_compressor/texture_compressor.h" // Use aligned memory for SIMD in texture compressor. -#define STB_IMAGE_IMPLEMENTATION #define STBI_NO_STDIO -#define STBI_MALLOC(sz) base::AlignedAlloc(sz, 16) -#define STBI_REALLOC_SIZED(p, oldsz, newsz) \ - base::AlignedRealloc(p, oldsz, newsz, 16) -#define STBI_FREE(p) base::AlignedFree(p) #include "third_party/stb/stb_image.h" using namespace base; diff --git a/src/engine/asset/sound.cc b/src/engine/asset/sound.cc index 32aea30..436cc50 100644 --- a/src/engine/asset/sound.cc +++ b/src/engine/asset/sound.cc @@ -3,11 +3,8 @@ #include #include "base/log.h" -#define MINIMP3_ONLY_MP3 -#define MINIMP3_ONLY_SIMD #define MINIMP3_FLOAT_OUTPUT #define MINIMP3_NO_STDIO -#define MINIMP3_IMPLEMENTATION #include "engine/engine.h" #include "engine/platform/asset_file.h" #include "third_party/minimp3/minimp3_ex.h" diff --git a/src/third_party/BUILD.gn b/src/third_party/BUILD.gn index 9362f58..f3c4612 100644 --- a/src/third_party/BUILD.gn +++ b/src/third_party/BUILD.gn @@ -59,9 +59,11 @@ source_set("third_party") { "glslang/glslang/MachineIndependent/reflection.cpp", "jsoncpp/json.h", "jsoncpp/jsoncpp.cpp", + "minimp3/minimp3.cc", "minimp3/minimp3.h", "minimp3/minimp3_ex.h", "spirv-reflect/spirv_reflect.c", + "stb/stb_image.cc", "stb/stb_image.h", "stb/stb_truetype.h", "texture_compressor/dxt_encoder.cc", @@ -77,7 +79,7 @@ source_set("third_party") { "volk/volk.c", ] - defines = [ "VMA_STATIC_VULKAN_FUNCTIONS=1" ] + defines = [ "VMA_STATIC_VULKAN_FUNCTIONS=1", "GLEW_STATIC" ] if (target_os == "linux" || target_os == "win") { sources += [ @@ -101,6 +103,7 @@ source_set("third_party") { } configs -= [ "//build:warnings" ] + configs += [ "//build:third_party_warnings" ] deps = [] } diff --git a/src/third_party/minimp3/minimp3.cc b/src/third_party/minimp3/minimp3.cc new file mode 100644 index 0000000..b782bd1 --- /dev/null +++ b/src/third_party/minimp3/minimp3.cc @@ -0,0 +1,6 @@ +#define MINIMP3_ONLY_MP3 +#define MINIMP3_ONLY_SIMD +#define MINIMP3_FLOAT_OUTPUT +#define MINIMP3_NO_STDIO +#define MINIMP3_IMPLEMENTATION +#include "third_party/minimp3/minimp3_ex.h" diff --git a/src/third_party/stb/stb_image.cc b/src/third_party/stb/stb_image.cc new file mode 100644 index 0000000..770f613 --- /dev/null +++ b/src/third_party/stb/stb_image.cc @@ -0,0 +1,10 @@ +#include "base/mem.h" + +// Use aligned memory for SIMD in texture compressor. +#define STB_IMAGE_IMPLEMENTATION +#define STBI_NO_STDIO +#define STBI_MALLOC(sz) base::AlignedAlloc(sz, 16) +#define STBI_REALLOC_SIZED(p, oldsz, newsz) \ + base::AlignedRealloc(p, oldsz, newsz, 16) +#define STBI_FREE(p) base::AlignedFree(p) +#include "third_party/stb/stb_image.h"