A preprocessor "trick" not mentioned in the article is the use of GNU statement expressions.
The article describes the do {} while(0) trick to make macros look like statements. They can then basically be used like inline void function calls. But what if you want to write a macro to replace an inline function that returns a result?
Statement expressions [1] solve that problem. Now you can finally do this:
> A preprocessor "trick" not mentioned in the article is the use of GNU statement expressions.
That's probably because IAR sells compilers (and IDEs) for embedded software. IAR and Keil are the popular compilers in the "bare bones microcontroller C/Assembly" world.
The article describes the do {} while(0) trick to make macros look like statements. They can then basically be used like inline void function calls. But what if you want to write a macro to replace an inline function that returns a result?
Statement expressions [1] solve that problem. Now you can finally do this:
They are supported by most popular compilers which are not made by Microsoft (including GCC and clang).[1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html