From 9fef5b1e9499282e16473c1ef61d9a1a0691e9c6 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Fri, 18 Sep 2020 09:09:44 +0100 Subject: [PATCH] AP_Scripting: remove compile errors and warnings --- libraries/AP_Scripting/lua/src/lcode.c | 3 +++ libraries/AP_Scripting/lua/src/lstrlib.c | 3 +++ libraries/AP_Scripting/lua/src/ltable.c | 3 +++ libraries/AP_Scripting/lua/src/lundump.c | 3 +++ libraries/AP_Scripting/lua_boxed_numerics.cpp | 2 +- libraries/AP_Scripting/wscript | 7 ++++--- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Scripting/lua/src/lcode.c b/libraries/AP_Scripting/lua/src/lcode.c index 48ef89d451..80133cdeca 100644 --- a/libraries/AP_Scripting/lua/src/lcode.c +++ b/libraries/AP_Scripting/lua/src/lcode.c @@ -9,6 +9,9 @@ #if defined(ARDUPILOT_BUILD) #pragma GCC diagnostic ignored "-Wfloat-equal" +#if defined(__GNUC__) && __GNUC__ >= 7 || defined(__clang_major__) && __clang_major__ >= 11 +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif #endif #include "lprefix.h" diff --git a/libraries/AP_Scripting/lua/src/lstrlib.c b/libraries/AP_Scripting/lua/src/lstrlib.c index af44efbb4f..a687b9942e 100644 --- a/libraries/AP_Scripting/lua/src/lstrlib.c +++ b/libraries/AP_Scripting/lua/src/lstrlib.c @@ -26,6 +26,9 @@ #if defined(ARDUPILOT_BUILD) #pragma GCC diagnostic ignored "-Wunused-function" +#if defined(__GNUC__) && __GNUC__ >= 7 || defined(__clang_major__) && __clang_major__ >= 11 +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif #endif diff --git a/libraries/AP_Scripting/lua/src/ltable.c b/libraries/AP_Scripting/lua/src/ltable.c index 2c3cbaef56..d278e4a781 100644 --- a/libraries/AP_Scripting/lua/src/ltable.c +++ b/libraries/AP_Scripting/lua/src/ltable.c @@ -9,6 +9,9 @@ #if defined(ARDUPILOT_BUILD) #pragma GCC diagnostic ignored "-Wfloat-equal" +#if defined(__GNUC__) && __GNUC__ >= 7 || defined(__clang_major__) && __clang_major__ >= 11 +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif #endif #include "lprefix.h" diff --git a/libraries/AP_Scripting/lua/src/lundump.c b/libraries/AP_Scripting/lua/src/lundump.c index d2c8f3f070..4b0f9a5ab9 100644 --- a/libraries/AP_Scripting/lua/src/lundump.c +++ b/libraries/AP_Scripting/lua/src/lundump.c @@ -6,6 +6,9 @@ #if defined(ARDUPILOT_BUILD) #pragma GCC diagnostic ignored "-Wfloat-equal" +#if defined(__GNUC__) && __GNUC__ >= 7 || defined(__clang_major__) && __clang_major__ >= 11 +#pragma GCC diagnostic ignored "-Wstring-plus-int" +#endif #endif #define lundump_c diff --git a/libraries/AP_Scripting/lua_boxed_numerics.cpp b/libraries/AP_Scripting/lua_boxed_numerics.cpp index 48dc3c4c40..065bca77e4 100644 --- a/libraries/AP_Scripting/lua_boxed_numerics.cpp +++ b/libraries/AP_Scripting/lua_boxed_numerics.cpp @@ -26,7 +26,7 @@ uint32_t coerce_to_uint32_t(lua_State *L, int arg) { { // float int success; const lua_Number v = lua_tonumberx(L, arg, &success); - if (success && v >= 0 && v <= UINT32_MAX) { + if (success && v >= 0 && v <= float(UINT32_MAX)) { return static_cast(v); } } diff --git a/libraries/AP_Scripting/wscript b/libraries/AP_Scripting/wscript index b4cc613e58..14fbd1c326 100644 --- a/libraries/AP_Scripting/wscript +++ b/libraries/AP_Scripting/wscript @@ -7,8 +7,9 @@ build generated bindings from bindings.desc for AP_Scripting from waflib.TaskGen import after_method, before_method, feature import os -CFLAGS="-std=c99 -Wno-error=missing-field-initializers -Wall -Werror -Wextra" -CC="gcc" +# these are only used for binding generation, not compilation of the library +BINDING_CFLAGS="-std=c99 -Wno-error=missing-field-initializers -Wall -Werror -Wextra" +BINDING_CC="gcc" def configure(cfg): cfg.env.AP_LIB_EXTRA_SOURCES['AP_Scripting'] = ['lua_generated_bindings.cpp'] @@ -30,7 +31,7 @@ def build(bld): source=main_c, target=[gen_bindings], # we should have configure tests for finding the native compiler - rule="%s %s -o %s %s" % (CC, CFLAGS, gen_bindings_rel, main_c_rel), + rule="%s %s -o %s %s" % (BINDING_CC, BINDING_CFLAGS, gen_bindings_rel, main_c_rel), group='dynamic_sources', )