From b540364f3842fe6ea41a908c905e12e4458e4fef Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 16 Sep 2024 08:50:50 -0700 Subject: Fix warnings. --- cassert/CMakeLists.txt | 4 ++++ cassert/include/cassert.h | 17 +++++------------ log/CMakeLists.txt | 6 ++++++ log/include/log/log.h | 23 +++++------------------ 4 files changed, 20 insertions(+), 30 deletions(-) diff --git a/cassert/CMakeLists.txt b/cassert/CMakeLists.txt index 13e5560..fedb082 100644 --- a/cassert/CMakeLists.txt +++ b/cassert/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.5) project(cassert) +set(CMAKE_C_STANDARD 23) +set(CMAKE_C_STANDARD_REQUIRED On) +set(CMAKE_C_EXTENSIONS Off) + add_library(cassert INTERFACE) target_include_directories(cassert INTERFACE diff --git a/cassert/include/cassert.h b/cassert/include/cassert.h index bb98f50..590f684 100644 --- a/cassert/include/cassert.h +++ b/cassert/include/cassert.h @@ -6,18 +6,11 @@ // Allow the client to define their own LOGE() macro. #ifndef LOGE #include -// __VA_OPT__ is not available until C2X. -/*#define LOGE(format, ...) \ - { \ - fprintf( \ - stderr, "[ASSERT] %s:%d " format "\n", __FILE__, \ - __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ - }*/ -#define LOGE(...) \ - { \ - fprintf(stderr, "[ASSERT] %s:%d ", __FILE__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ +#define LOGE(...) \ + { \ + fprintf(stderr, "[ASSERT] %s:%d", __FILE__, __LINE__); \ + fprintf(stderr, " " __VA_ARGS__); \ + fprintf(stderr, "\n"); \ } #endif // LOGE diff --git a/log/CMakeLists.txt b/log/CMakeLists.txt index cc103c5..615e200 100644 --- a/log/CMakeLists.txt +++ b/log/CMakeLists.txt @@ -1,5 +1,11 @@ cmake_minimum_required(VERSION 3.5) +project(log) + +set(CMAKE_C_STANDARD 23) +set(CMAKE_C_STANDARD_REQUIRED On) +set(CMAKE_C_EXTENSIONS Off) + add_library(log src/log.c) diff --git a/log/include/log/log.h b/log/include/log/log.h index c660881..f94ba84 100644 --- a/log/include/log/log.h +++ b/log/include/log/log.h @@ -10,24 +10,11 @@ #undef LOGW #undef LOGE -// __VA_OPT__ is not available until C2X. -/*#define LOG(channel, tag, format, ...) \ - { \ - fprintf( \ - channel, "[%s] %s:%d " format "\n", #tag, __FILE__, \ - __LINE__ __VA_OPT__(, ) __VA_ARGS__); \ - }*/ - -/*#define LOGD(format, ...) LOG(stdout, DEBUG, format, __VA_ARGS__) -#define LOGI(format, ...) LOG(stdout, INFO, format, __VA_ARGS__) -#define LOGW(format, ...) LOG(stdout, WARN, format, __VA_ARGS__) -#define LOGE(format, ...) LOG(stderr, ERROR, format, __VA_ARGS__)*/ - -#define LOG(channel, tag, ...) \ - { \ - fprintf(channel, "[%s] %s:%d ", #tag, __FILE__, __LINE__); \ - fprintf(channel, __VA_ARGS__); \ - fprintf(channel, "\n"); \ +#define LOG(channel, tag, ...) \ + { \ + fprintf(channel, "[%s] %s:%d", #tag, __FILE__, __LINE__); \ + fprintf(channel, " " __VA_ARGS__); \ + fprintf(channel, "\n"); \ } #define LOGD(...) LOG(stdout, DEBUG, __VA_ARGS__) -- cgit v1.2.3