#cpreprocessor

Luke T. Shumakerlukeshu@social.coop
2025-05-15

#define LM_IS_EMPTY_TUPLE(x) LM_SECOND_(_LM_IS_EMPTY_TUPLE x, LM_F)
#define _LM_IS_EMPTY_TUPLE(...) bogus, __VA_OPT__(LM_F,) LM_T

Yes, this is a good way to write code. There is nothing wrong with the language forcing you to do things like this. #CPreProcessor

N-gated Hacker Newsngate
2025-03-23

Ah, the C preprocessor—because nothing screams "optimize" like using a tool meant for text substitution to interpret 🧠💩. GitHub's cutting-edge has finally made it possible to over-engineer obsolescence. Next up: using Excel macros to land rockets 🚀📉.
github.com/camel-cdr/bfcpp

2024-04-06

C++ isn't a serious language.

today's bullshit:

template<typename T, typename U, U T::* Member>
struct get_offset {
static constexpr size_t offset = offsetof(T, Member);
};

struct Example {
int x;
};

const size_t N = get_offset<Example, int, &Example::x>::offset;

This doesn't compile with clang. because...

1/2

2024-03-06

I wonder if anyone has seriously thought about adding some kind of namespacing to the C preprocessor.

for example, it would be nice if you could say

FOO
"foo.h"

and then all the preprocessor defines from foo.h are brought into your file with names like FOO##

2023-12-18

my #DecemberAdventure has mostly been implementing in #Lua a #compiler from a subset of Lua to #C99, eventually aiming to target #OpenCL #C, with the end goal of number-type-generic #GPU -accelerated #fractal #graphics stuff.

Previously I was doing it with #CPreProcessor macro hell, compare this #MandelbrotSet inner loop:

before, lines 44 to 65 code.mathr.co.uk/carrottuba/bl
after, lines 22 to 38 code.mathr.co.uk/carrottuba/bl

2021-02-01

Found a bug in #zoomasm's 360 projection (the distance estimate scaling was wrong).

Trying to do the maths by hand is too hard, so I copied my #GLSL #DualNumber implementation (for #AutomaticDifferentiation) from my fragm-examples repository, minus the #CPreProcessor macro hell, plus some quaternion-to-rotation-matrix code ported from Python that I found online.

Now it looks okish in the #equirectangular view, need to render some tests at various orientations and inject spatial metadata for viewing in VLC to be more sure I got it right...

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst