Skip to content

Commit 69a9228

Browse files
committed
Clarification to AM_DO_ONCE(), AM_DO_EACH_MS() and AM_DO_EVERY() macros
1 parent 7e605c2 commit 69a9228

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [0-based versioning](https://0ver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Clarification to `AM_DO_ONCE()`, `AM_DO_EACH_MS()` and `AM_DO_EVERY()` macros.
13+
1014
## v0.14.0 - 24-August-2025
1115

1216
### Changed

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"Wcast",
129129
"nbusy",
130130
"npools",
131+
"smth",
131132
],
132133
// flagWords - list of words to be always considered incorrect
133134
// This is useful for offensive words and common spelling errors.

libs/common/macros.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,20 @@ AM_NORETURN void am_assert_failure(
119119
* ++i;
120120
* }
121121
* }
122+
*
123+
* Note:
124+
*
125+
* The macro requires explicit curly braces, when used
126+
* in the context of if, switch-case, for, while:
127+
*
128+
* E.g., this is correct:
129+
*
130+
* if (smth) { AM_DO_EVERY(2) {smth} }
131+
*
132+
* This is NOT correct and will not compile:
133+
*
134+
* if (smth) AM_DO_EVERY(2) {smth}
135+
*
122136
* after iteration number| i
123137
* ----------------------+--
124138
* 1 | 1
@@ -144,6 +158,19 @@ AM_NORETURN void am_assert_failure(
144158
* }
145159
* }
146160
*
161+
* Note:
162+
*
163+
* The macro requires explicit curly braces, when used
164+
* in the context of if, switch-case, for, while:
165+
*
166+
* E.g., this is correct:
167+
*
168+
* if (smth) { AM_DO_ONCE() {smth} }
169+
*
170+
* This is NOT correct and will not compile:
171+
*
172+
* if (smth) AM_DO_ONCE() {smth}
173+
*
147174
* after iteration number| i
148175
* ----------------------+--
149176
* 1 | 1
@@ -158,6 +185,19 @@ AM_NORETURN void am_assert_failure(
158185
* Execute code in the attached scope immediately and
159186
* then repeatedly every \p ms milliseconds.
160187
*
188+
* Note:
189+
*
190+
* The macro requires explicit curly braces, when used
191+
* in the context of if, switch-case, for, while:
192+
*
193+
* E.g., this is correct:
194+
*
195+
* if (smth) { AM_DO_EACH_MS(5) {smth} }
196+
*
197+
* This is NOT correct and will not compile:
198+
*
199+
* if (smth) AM_DO_EACH_MS(5) {smth}
200+
*
161201
* Example:
162202
* AM_DO_EACH_MS(100) {
163203
* am_pal_printf("Hello, world!\n");

0 commit comments

Comments
 (0)