Skip to content

Commit 66fc096

Browse files
committed
Redefine AM_JOINSTR() in common/compiler.h to avoid cross-include with common/macros.h
1 parent c58611f commit 66fc096

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

libs/async/test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <string.h>
2828

29+
#include "common/compiler.h"
2930
#include "common/macros.h"
3031

3132
#include "async/async.h"

libs/common/compiler.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,28 +446,45 @@
446446
AM_ENABLE_WARNING(AM_W_DATE_TIME) \
447447
AM_ENABLE_WARNING(AM_W_NULL_DEREFERENCE)
448448

449+
/** Internal stringification macro helper. */
450+
#define AM_STRINGIFY_IMPL2(s) #s
451+
/** Internal stringification macro. */
452+
#define AM_STRINGIFY_IMPL(s) AM_STRINGIFY_IMPL2(s)
453+
/** Join x and y together. */
454+
#define AM_JOINSTR_(x, y) AM_STRINGIFY_IMPL(x##y)
455+
449456
#if (AM_COMPILER_ID == AM_COMPILER_CLANG)
457+
450458
#define AM_DISABLE_WARNING(warning) \
451459
AM_DIAG_PRAGMA(clang, push) \
452460
AM_DIAG_PRAGMA(clang, ignored AM_JOINSTR_(-W, warning))
453461
#define AM_ENABLE_WARNING(warning) AM_DIAG_PRAGMA(clang, pop)
462+
454463
#elif defined(_MSC_VER)
464+
455465
#define AM_DISABLE_WARNING(warning) \
456466
AM_DIAG_PRAGMA(msvc, push) \
457467
AM_DIAG_DO_PRAGMA(warning(disable :##warning))
458468
#define AM_ENABLE_WARNING(warning) AM_DIAG_PRAGMA(msvc, pop)
469+
459470
#elif (AM_COMPILER_ID == AM_COMPILER_GCC)
471+
460472
#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
473+
461474
#define AM_DISABLE_WARNING(warning) \
462475
AM_DIAG_PRAGMA(GCC, push) \
463476
AM_DIAG_PRAGMA(GCC, ignored AM_JOINSTR_(-W, warning))
464477
#define AM_ENABLE_WARNING(warning) AM_DIAG_PRAGMA(GCC, pop)
478+
465479
#else
480+
466481
#define AM_DISABLE_WARNING(warning) \
467482
AM_DIAG_PRAGMA(GCC, ignored AM_JOINSTR_(-W, warning))
468483
#define AM_ENABLE_WARNING(warning) \
469484
AM_DIAG_PRAGMA(GCC, warning AM_JOINSTR_(-W, warning))
485+
470486
#endif /* __GNUC__ */
487+
471488
#endif /* AM_COMPILER_ID */
472489

473490
/* taken from https://github.com/sustrik/libdill */

libs/common/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ AM_NORETURN void am_assert_failure(
132132
#define AM_STRINGIFY_(s) #s
133133
#define AM_STRINGIFY(s) AM_STRINGIFY_(s)
134134
/** Join x and y together. */
135-
#define AM_JOINSTR_(x, y) AM_STRINGIFY(x##y)
135+
#define AM_JOINSTR(x, y) AM_STRINGIFY(x##y)
136136

137137
/** Counts the number of trailing zeros in a word. */
138138
#define AM_COUNT_TRAILING_ZEROS(word) \

libs/strlib/strlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <inttypes.h>
4242
#include <stdbool.h>
4343

44-
#include "common/macros.h"
44+
#include "common/compiler.h"
4545

4646
#ifdef __cplusplus
4747
extern "C" {

libs/strlib/test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <string.h>
3838

3939
#include "common/macros.h"
40+
#include "common/compiler.h"
4041
#include "strlib/strlib.h"
4142

4243
static void string_is_true(const char *str) {

libs/timer/timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
#include <stdbool.h>
3737

38-
#include "common/macros.h"
38+
#include "common/compiler.h"
3939
#include "event/event.h"
4040
#include "slist/slist.h"
4141
#include "pal/pal.h"

0 commit comments

Comments
 (0)