Skip to content

Commit 72d35c7

Browse files
committed
[docs] Document MODM_DEBUG_BUILD macro behavior
1 parent 01328aa commit 72d35c7

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/modm/architecture/detect.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
/// Size of pointer in bytes
8585
#define MODM_SIZEOF_POINTER
8686

87+
/// Only defined in debug profile
88+
#define MODM_DEBUG_BUILD
89+
8790
/// @}
8891

8992
#else // !__DOXYGEN__

src/modm/architecture/interface/assert.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ just as above:
175175
4. `bool modm_assert_continue_fail_debug()`
176176
5. `bool modm_assert_continue_ignore_debug()`
177177

178+
Alternatively, you can guard the entire assertion statement with the
179+
`MODM_BUILD_DEBUG` macro if you only want to execute the check and branch in
180+
debug profile:
181+
182+
```cpp
183+
// The check is always performed, but only raises an assertion in debug profile!
184+
if (not modm_assert_continue_ignore_debug(cond, ...))
185+
{
186+
// if the check fails, this branch is executed in release profile too!
187+
}
188+
189+
#ifdef MODM_DEBUG_BUILD
190+
// This check if only performed in debug profile
191+
if (not modm_assert_continue_ignore(cond, ...))
192+
{
193+
// if the check fails, this branch is executed only in debug profile!
194+
}
195+
#endif
196+
```
197+
178198
179199
### When to use what?
180200

tools/build_script_generator/module.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ For *release builds*:
3636
For *debug builds*:
3737

3838
- `-Og`: optimize for debugging experience.
39+
- `MODM_DEBUG_BUILD`: this macro is only defined in debug profile. You can use
40+
it with `#ifdef MODM_DEBUG_BUILD` to enable debug code.
3941

4042
#### Only C
4143

0 commit comments

Comments
 (0)