Skip to content

Commit 9c67bf6

Browse files
committed
Change MBED_STATIC_ASSERTs version for built-in
1 parent 83fa121 commit 9c67bf6

File tree

30 files changed

+109
-105
lines changed

30 files changed

+109
-105
lines changed

TESTS/mbedmicro-mbed/static_assert/test_c.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,36 @@
2222
// multiple asserts are used to guarantee no conflicts occur in generated labels
2323

2424
// Test for static asserts in global context
25-
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
26-
"An int must be larger than char");
27-
MBED_STATIC_ASSERT(2 + 2 == 4,
28-
"Hopefully the universe is mathematically consistent");
29-
MBED_STATIC_ASSERT(THE_ANSWER == 42,
30-
"Said Deep Thought, with infinite majesty and calm");
25+
static_assert(sizeof(int) >= sizeof(char),
26+
"An int must be larger than char");
27+
static_assert(2 + 2 == 4,
28+
"Hopefully the universe is mathematically consistent");
29+
static_assert(THE_ANSWER == 42,
30+
"Said Deep Thought, with infinite majesty and calm");
3131

3232
struct test {
3333
int dummy;
3434

3535
// Test for static asserts in struct context
36-
MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char),
37-
"An int must be larger than char");
38-
MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4,
39-
"Hopefully the universe is mathematically consistent");
40-
MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42,
41-
"Said Deep Thought, with infinite majesty and calm");
36+
static_assert(sizeof(int) >= sizeof(char),
37+
"An int must be larger than char");
38+
static_assert(2 + 2 == 4,
39+
"Hopefully the universe is mathematically consistent");
40+
static_assert(THE_ANSWER == 42,
41+
"Said Deep Thought, with infinite majesty and calm");
4242
};
4343

44-
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
45-
"Static assertions should not change the size of a struct");
44+
static_assert(sizeof(struct test) == sizeof(int),
45+
"Static assertions should not change the size of a struct");
4646

4747
void doit_c(void)
4848
{
4949
// Test for static asserts in function context
50-
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
51-
"An int must be larger than char");
52-
MBED_STATIC_ASSERT(2 + 2 == 4,
53-
"Hopefully the universe is mathematically consistent");
54-
MBED_STATIC_ASSERT(THE_ANSWER == 42,
55-
"Said Deep Thought, with infinite majesty and calm");
50+
static_assert(sizeof(int) >= sizeof(char),
51+
"An int must be larger than char");
52+
static_assert(2 + 2 == 4,
53+
"Hopefully the universe is mathematically consistent");
54+
static_assert(THE_ANSWER == 42,
55+
"Said Deep Thought, with infinite majesty and calm");
5656
}
5757

TESTS/mbedmicro-mbed/static_assert/test_cpp.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,43 @@
2222
// multiple asserts are used to guarantee no conflicts occur in generated labels
2323

2424
// Test for static asserts in global context
25-
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
26-
"An int must be larger than char");
27-
MBED_STATIC_ASSERT(2 + 2 == 4,
28-
"Hopefully the universe is mathematically consistent");
29-
MBED_STATIC_ASSERT(THE_ANSWER == 42,
30-
"Said Deep Thought, with infinite majesty and calm");
25+
static_assert(sizeof(int) >= sizeof(char),
26+
"An int must be larger than char");
27+
static_assert(2 + 2 == 4,
28+
"Hopefully the universe is mathematically consistent");
29+
static_assert(THE_ANSWER == 42,
30+
"Said Deep Thought, with infinite majesty and calm");
3131

3232
struct test {
3333
int dummy;
3434

3535
// Test for static asserts in struct context
36-
MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char),
37-
"An int must be larger than char");
38-
MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4,
39-
"Hopefully the universe is mathematically consistent");
40-
MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42,
41-
"Said Deep Thought, with infinite majesty and calm");
36+
static_assert(sizeof(int) >= sizeof(char),
37+
"An int must be larger than char");
38+
static_assert(2 + 2 == 4,
39+
"Hopefully the universe is mathematically consistent");
40+
static_assert(THE_ANSWER == 42,
41+
"Said Deep Thought, with infinite majesty and calm");
4242

43-
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
44-
"An int must be larger than char");
45-
MBED_STATIC_ASSERT(2 + 2 == 4,
46-
"Hopefully the universe is mathematically consistent");
47-
MBED_STATIC_ASSERT(THE_ANSWER == 42,
48-
"Said Deep Thought, with infinite majesty and calm");
43+
static_assert(sizeof(int) >= sizeof(char),
44+
"An int must be larger than char");
45+
static_assert(2 + 2 == 4,
46+
"Hopefully the universe is mathematically consistent");
47+
static_assert(THE_ANSWER == 42,
48+
"Said Deep Thought, with infinite majesty and calm");
4949
};
5050

51-
MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int),
52-
"Static assertions should not change the size of a struct");
51+
static_assert(sizeof(struct test) == sizeof(int),
52+
"Static assertions should not change the size of a struct");
5353

5454
void doit_c(void)
5555
{
5656
// Test for static asserts in function context
57-
MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char),
58-
"An int must be larger than char");
59-
MBED_STATIC_ASSERT(2 + 2 == 4,
60-
"Hopefully the universe is mathematically consistent");
61-
MBED_STATIC_ASSERT(THE_ANSWER == 42,
62-
"Said Deep Thought, with infinite majesty and calm");
57+
static_assert(sizeof(int) >= sizeof(char),
58+
"An int must be larger than char");
59+
static_assert(2 + 2 == 4,
60+
"Hopefully the universe is mathematically consistent");
61+
static_assert(THE_ANSWER == 42,
62+
"Said Deep Thought, with infinite majesty and calm");
6363
}
6464

connectivity/FEATURE_BLE/include/ble/common/ble/Duration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct Duration {
140140
Duration(Duration<OtherRep, OtherTB, OtherRange, OtherF> other) :
141141
duration(clamp(other.value() * (OtherTB / TB)))
142142
{
143-
MBED_STATIC_ASSERT(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units");
143+
static_assert(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units");
144144
}
145145

146146
/**

connectivity/netsocket/source/NetworkStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class NetworkStackWrapper : public NetworkStack {
430430
// Conversion function for network stacks
431431
NetworkStack *nsapi_create_stack(nsapi_stack_t *stack)
432432
{
433-
MBED_STATIC_ASSERT(sizeof stack->_stack_buffer >= sizeof(NetworkStackWrapper),
434-
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
433+
static_assert(sizeof stack->_stack_buffer >= sizeof(NetworkStackWrapper),
434+
"The nsapi_stack_t stack buffer must fit a NetworkStackWrapper");
435435
return new (stack->_stack_buffer) NetworkStackWrapper;
436436
}

drivers/source/MbedCRC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace mbed {
2323

2424
SingletonPtr<PlatformMutex> mbed_crc_mutex;
2525

26-
MBED_STATIC_ASSERT(MBED_CRC_TABLE_SIZE == 0 || MBED_CRC_TABLE_SIZE == 16 || MBED_CRC_TABLE_SIZE == 256,
27-
"Configuration setting drivers.crc-table-size must be set to 0, 16 or 256");
26+
static_assert(MBED_CRC_TABLE_SIZE == 0 || MBED_CRC_TABLE_SIZE == 16 || MBED_CRC_TABLE_SIZE == 256,
27+
"Configuration setting drivers.crc-table-size must be set to 0, 16 or 256");
2828

2929
#if MBED_CRC_TABLE_SIZE > 0
3030

events/source/equeue_mbed.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ static void equeue_tick_update()
105105

106106
void equeue_tick_init()
107107
{
108-
MBED_STATIC_ASSERT(sizeof(equeue_timer) >= sizeof(ALIAS_TIMER),
109-
"The equeue_timer buffer must fit the class Timer");
110-
MBED_STATIC_ASSERT(sizeof(equeue_ticker) >= sizeof(ALIAS_TICKER),
111-
"The equeue_ticker buffer must fit the class Ticker");
108+
static_assert(sizeof(equeue_timer) >= sizeof(ALIAS_TIMER),
109+
"The equeue_timer buffer must fit the class Timer");
110+
static_assert(sizeof(equeue_ticker) >= sizeof(ALIAS_TICKER),
111+
"The equeue_ticker buffer must fit the class Ticker");
112112
ALIAS_TIMER *timer = new (equeue_timer) ALIAS_TIMER;
113113
ALIAS_TICKER *ticker = new (equeue_ticker) ALIAS_TICKER;
114114

@@ -155,7 +155,7 @@ void equeue_mutex_unlock(equeue_mutex_t *m)
155155

156156
#include "rtos/EventFlags.h"
157157

158-
MBED_STATIC_ASSERT(sizeof(equeue_sema_t) == sizeof(rtos::EventFlags), "equeue_sema_t / rtos::EventFlags mismatch");
158+
static_assert(sizeof(equeue_sema_t) == sizeof(rtos::EventFlags), "equeue_sema_t / rtos::EventFlags mismatch");
159159

160160
int equeue_sema_create(equeue_sema_t *s)
161161
{

features/frameworks/utest/utest/utest_specification.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace v1 {
5555
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
5656
defaults(defaults)
5757
{
58-
MBED_STATIC_ASSERT(
58+
static_assert(
5959
sizeof(CaseType) == sizeof(Case),
6060
"CaseType and Case should have the same size"
6161
);
@@ -69,7 +69,7 @@ namespace v1 {
6969
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
7070
defaults(defaults)
7171
{
72-
MBED_STATIC_ASSERT(
72+
static_assert(
7373
sizeof(CaseType) == sizeof(Case),
7474
"CaseType and Case should have the same size"
7575
);
@@ -83,7 +83,7 @@ namespace v1 {
8383
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
8484
defaults(defaults)
8585
{
86-
MBED_STATIC_ASSERT(
86+
static_assert(
8787
sizeof(CaseType) == sizeof(Case),
8888
"CaseType and Case should have the same size"
8989
);
@@ -98,7 +98,7 @@ namespace v1 {
9898
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
9999
defaults(defaults)
100100
{
101-
MBED_STATIC_ASSERT(
101+
static_assert(
102102
sizeof(CaseType) == sizeof(Case),
103103
"CaseType and Case should have the same size"
104104
);
@@ -122,7 +122,7 @@ namespace v1 {
122122
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
123123
defaults(defaults)
124124
{
125-
MBED_STATIC_ASSERT(
125+
static_assert(
126126
sizeof(CaseType) == sizeof(Case),
127127
"CaseType and Case should have the same size"
128128
);
@@ -137,7 +137,7 @@ namespace v1 {
137137
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
138138
defaults(defaults)
139139
{
140-
MBED_STATIC_ASSERT(
140+
static_assert(
141141
sizeof(CaseType) == sizeof(Case),
142142
"CaseType and Case should have the same size"
143143
);
@@ -153,7 +153,7 @@ namespace v1 {
153153
cases(static_cast<const Case*>(static_cast<const CaseType*>(cases))), length(N),
154154
defaults(defaults)
155155
{
156-
MBED_STATIC_ASSERT(
156+
static_assert(
157157
sizeof(CaseType) == sizeof(Case),
158158
"CaseType and Case should have the same size"
159159
);

hal/mbed_pinmap_default.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ static const PinList ff_arduino_list = {
4242
ff_arduino_pins
4343
};
4444

45-
MBED_STATIC_ASSERT(sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]) == sizeof(ff_arduino_names) / sizeof(ff_arduino_names[0]),
46-
"Arrays must have the same length");
45+
static_assert(sizeof(ff_arduino_pins) / sizeof(ff_arduino_pins[0]) == sizeof(ff_arduino_names) / sizeof(ff_arduino_names[0]),
46+
"Arrays must have the same length");
4747

4848
const PinList *pinmap_ff_arduino_pins()
4949
{

hal/mpu/mbed_mpu_v7m.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#endif
3434
#define MBED_MPU_RAM_START (MBED_MPU_ROM_END + 1)
3535

36-
MBED_STATIC_ASSERT(
36+
static_assert(
3737
MBED_MPU_ROM_END == 0x04000000 - 1 ||
3838
MBED_MPU_ROM_END == 0x08000000 - 1 ||
3939
MBED_MPU_ROM_END == 0x0C000000 - 1 ||

hal/mpu/mbed_mpu_v8m.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#endif
3434
#define MBED_MPU_RAM_START (MBED_MPU_ROM_END + 1)
3535

36-
MBED_STATIC_ASSERT(MBED_MPU_ROM_END <= 0x20000000 - 1,
37-
"Unsupported value for MBED_MPU_ROM_END");
36+
static_assert(MBED_MPU_ROM_END <= 0x20000000 - 1,
37+
"Unsupported value for MBED_MPU_ROM_END");
3838

3939
void mbed_mpu_init()
4040
{

0 commit comments

Comments
 (0)