Makefile: move to c++17 to use [[maybe_unused]] and remove DEFER (actually not used) from macros.h

This commit is contained in:
Robert Swiecki 2023-09-21 08:29:36 +02:00
parent 439606be70
commit 557633c1de
3 changed files with 2 additions and 28 deletions

View File

@ -32,7 +32,7 @@ COMMON_FLAGS += -O2 -c \
-Ikafel/include
CXXFLAGS += $(USER_DEFINES) $(COMMON_FLAGS) $(shell pkg-config --cflags protobuf) \
-std=c++14 -fno-exceptions -Wno-unused -Wno-unused-parameter
-std=c++17 -fno-exceptions -Wno-unused -Wno-unused-parameter
LDFLAGS += -pie -Wl,-z,noexecstack -lpthread $(shell pkg-config --libs protobuf)
BIN = nsjail

View File

@ -37,32 +37,6 @@
#if !defined(ARR_SZ)
#define ARR_SZ(array) (sizeof(array) / sizeof(*array))
#endif /* !defined(ARR_SZ) */
#define UNUSED __attribute__((unused))
#if 0 /* Works, but needs -fblocks and libBlocksRuntime with clang */
/* Go-style defer implementation */
#define __STRMERGE(a, b) a##b
#define _STRMERGE(a, b) __STRMERGE(a, b)
#ifdef __clang__
static void __attribute__ ((unused)) __clang_cleanup_func(void (^*dfunc) (void))
{
(*dfunc) ();
}
#define defer \
void (^_STRMERGE(__defer_f_, __COUNTER__))(void) \
__attribute__((cleanup(__clang_cleanup_func))) __attribute__((unused)) = ^
#else
#define __block
#define _DEFER(a, count) \
auto void _STRMERGE(__defer_f_, count)(void* _defer_arg __attribute__((unused))); \
int _STRMERGE(__defer_var_, count) __attribute__((cleanup(_STRMERGE(__defer_f_, count)))) \
__attribute__((unused)); \
void _STRMERGE(__defer_f_, count)(void* _defer_arg __attribute__((unused)))
#define defer _DEFER(a, __COUNTER__)
#endif
#endif
#define NS_VALSTR_STRUCT(x) \
{ (uint64_t) x, #x }

View File

@ -520,7 +520,7 @@ static uint8_t cloneStack[128 * 1024] __attribute__((aligned(__BIGGEST_ALIGNMENT
/* Cannot be on the stack, as the child's stack pointer will change after clone() */
static __thread jmp_buf env;
[[noreturn]] static int cloneFunc(void* arg __attribute__((unused))) {
[[noreturn]] static int cloneFunc([[maybe_unused]] void* arg ) {
longjmp(env, 1);
LOG_F("Execution past longjmp");
}