Skip to content

Commit c18b0e5

Browse files
committed
Fix non-portable defines
A define which expands to more defines is not portable across all compilers and GCC warns about this. Restructure this so the behavior is defined. This fixes the GCC warning: "this use of "defined" may not be portable"
1 parent 953b925 commit c18b0e5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

platform/mbed_application.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121

2222
#include<stdint.h>
2323

24-
#define MBED_APPLICATION_SUPPORT defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_M7)
24+
#if defined(__CORTEX_M3) || defined(__CORTEX_M4) || defined(__CORTEX_M7)
25+
#define MBED_APPLICATION_SUPPORT 1
26+
#else
27+
#define MBED_APPLICATION_SUPPORT 0
28+
#endif
29+
2530
#if MBED_APPLICATION_SUPPORT
2631
#ifdef __cplusplus
2732
extern "C" {

platform/mbed_critical.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#include "platform/mbed_assert.h"
2424
#include "platform/mbed_toolchain.h"
2525

26-
#define EXCLUSIVE_ACCESS (!defined (__CORTEX_M0) && !defined (__CORTEX_M0PLUS))
26+
#if !defined (__CORTEX_M0) && !defined (__CORTEX_M0PLUS)
27+
#define EXCLUSIVE_ACCESS 1
28+
#else
29+
#define EXCLUSIVE_ACCESS 0
30+
#endif
2731

2832
static volatile uint32_t interrupt_enable_counter = 0;
2933
static volatile bool critical_interrupts_disabled = false;

0 commit comments

Comments
 (0)