From c456b64ed55ef670d6e81982fe57e1de75743546 Mon Sep 17 00:00:00 2001 From: harrand Date: Tue, 3 Dec 2024 13:58:56 +0000 Subject: [PATCH] [warnings] fix warnings from new clang version --- cmake/compiler.cmake | 2 +- include/tz/core/error.hpp | 3 ++- src/tz/core/lua.cpp | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 2041bc4120..f23a376129 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -22,7 +22,7 @@ endfunction() function(configure_gnu_like) # GNU-like compiler. i.e gcc + clang, but not msvc or clang-cl. # TODO - target_compile_options(topaz PRIVATE -Wall -Wextra -Werror -pedantic-errors) + target_compile_options(topaz PRIVATE -Wall -Wextra -Werror -pedantic-errors -Wno-missing-field-initializers) endfunction() function(configure_clang) diff --git a/include/tz/core/error.hpp b/include/tz/core/error.hpp index 3db26637bc..ee9096a796 100644 --- a/include/tz/core/error.hpp +++ b/include/tz/core/error.hpp @@ -1,6 +1,7 @@ #ifndef TOPAZ_CORE_ERROR_HPP #define TOPAZ_CORE_ERROR_HPP #include +#include #include namespace tz @@ -64,4 +65,4 @@ namespace tz } -#endif // TOPAZ_CORE_ERROR_HPP \ No newline at end of file +#endif // TOPAZ_CORE_ERROR_HPP diff --git a/src/tz/core/lua.cpp b/src/tz/core/lua.cpp index 2b55846f1b..04a6960b3e 100644 --- a/src/tz/core/lua.cpp +++ b/src/tz/core/lua.cpp @@ -98,7 +98,8 @@ namespace tz tz::error_code lua_define_function(std::string_view varname, lua_fn fn) { - lua_pushcfunction(lua, reinterpret_cast(fn)); + // note: this is undefined behaviour + lua_pushcfunction(lua, reinterpret_cast(reinterpret_cast(fn))); std::string tmp = std::format("tmp_{}", varname); lua_setglobal(lua, tmp.c_str()); lua_execute(std::format("{} = {}", varname, tmp)); @@ -254,4 +255,4 @@ namespace tz } return type; } -} \ No newline at end of file +}