Elektrine lite

← Feed

@fugueish@wandering.shop

Post #1707246

2026-04-26 23:39 UTC

Oh, you know, just committing some syntactic crimes. How's your Sunday goin’? ``` #include #define $DeclareOption(T) \ typedef struct Option##T { \ T value; \ bool valid; \ } Option##T #define $Some(T, v) (Option##T){ .value = v, .valid = true } int main() { $DeclareOption(int); auto o = $Some(int, 42); printf("%d %d\n", o.value, o.valid); } ```

Replies (1)

  • @joe@f.duriansoftware.com 2026-04-27 01:06

    @fugueish@wandering.shop with the C23 tag compatibility rules, I think you could even ditch the DeclareOptional by declaring the struct type in each initializer list

    Open ##1707245