Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
test_cpp.cpp
00001 #include "mbed_assert.h" 00002 #define THE_ANSWER 42 00003 00004 // Tests for static asserts in different contexts 00005 // multiple asserts are used to guarantee no conflicts occur in generated labels 00006 00007 // Test for static asserts in global context 00008 MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), 00009 "An int must be larger than char"); 00010 MBED_STATIC_ASSERT(2 + 2 == 4, 00011 "Hopefully the universe is mathematically consistent"); 00012 MBED_STATIC_ASSERT(THE_ANSWER == 42, 00013 "Said Deep Thought, with infinite majesty and calm"); 00014 00015 struct test { 00016 int dummy; 00017 00018 // Test for static asserts in struct context 00019 MBED_STRUCT_STATIC_ASSERT(sizeof(int) >= sizeof(char), 00020 "An int must be larger than char"); 00021 MBED_STRUCT_STATIC_ASSERT(2 + 2 == 4, 00022 "Hopefully the universe is mathematically consistent"); 00023 MBED_STRUCT_STATIC_ASSERT(THE_ANSWER == 42, 00024 "Said Deep Thought, with infinite majesty and calm"); 00025 00026 MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), 00027 "An int must be larger than char"); 00028 MBED_STATIC_ASSERT(2 + 2 == 4, 00029 "Hopefully the universe is mathematically consistent"); 00030 MBED_STATIC_ASSERT(THE_ANSWER == 42, 00031 "Said Deep Thought, with infinite majesty and calm"); 00032 }; 00033 00034 MBED_STATIC_ASSERT(sizeof(struct test) == sizeof(int), 00035 "Static assertions should not change the size of a struct"); 00036 00037 void doit_c(void) { 00038 // Test for static asserts in function context 00039 MBED_STATIC_ASSERT(sizeof(int) >= sizeof(char), 00040 "An int must be larger than char"); 00041 MBED_STATIC_ASSERT(2 + 2 == 4, 00042 "Hopefully the universe is mathematically consistent"); 00043 MBED_STATIC_ASSERT(THE_ANSWER == 42, 00044 "Said Deep Thought, with infinite majesty and calm"); 00045 } 00046
Generated on Fri Jul 22 2022 04:54:02 by
