DEV Community

Handy C/C++ Preprocessor Macros

Paul J. Lucas on January 02, 2024

Introduction Programming in either C or C++ invariably requires using preprocessor macros at some point. Here’s a collection of macros I...
Collapse
 
gberthiaume profile image
G. Berthiaume

I was not expecting to find such a high-quality low-level programming post on dev.to.
The STATIC_ASSERT_EXPR is brilliant.
Thanks for sharing.

Collapse
 
pauljlucas profile image
Paul J. Lucas • Edited

Thanks. I'm doing my part to raise the bar. The number of low-quality, poorly-written posts is eye-watering. FYI, it's no better on medium.

Collapse
 
gberthiaume profile image
G. Berthiaume • Edited

I agree. Maybe you could post links to your articles to lobste.rs. They would love your post over there.

In any case, I'm now following you. :)
Looking forward to reading your next C articles.

Thread Thread
 
pauljlucas profile image
Paul J. Lucas

I'd never heard of lobste.rs. I'll give it a look.

I'm currently spending time working on one of my open-source projects rather that writing. In the mean time, there's all my previous articles to read.

Collapse
 
pgradot profile image
Pierre Gradot

I never realized (or I forgot, that's also quite possible) that LINE is the same for all the lines that a macro expands to :o

Collapse
 
pauljlucas profile image
Paul J. Lucas

A macro always expands to a single line. Remember: escaped newlines are eliminated prior to expansion.