4 Comments
User's avatar
Himanshu Likhar's avatar

I hope Claude never writes such beautiful code.

PS: Great article as always, Abhinav. Got to learn something new.

A shocked bystander's avatar

This is C gore.

The #ifndef solution is the only correct one.

Imagine you're debugging this code and now have to read through 3 files to understand this clang hack in order to learn if it is even relevant to your platform. Plus you can not even be sure if LTO will catch it when it comes to performance. With the #ifndef it would just deal with it in place, where a reader would care about it and you'd immediately see if the code lands in your build or not.

This is not clean code at all, this is tech debt it should not be admired as "elegant".

JB's avatar
Jun 23Edited

Oh 100%

Admittedly I’m a little rusty with C these days but a global variable designed to handle an edge case just doesn’t feel like good programming

Seung Yun Lee's avatar

Such a fun read! Love a good macro tricks like these