#define

8 posts · Last used 1h

Back to Timeline
In reply to
@joe@f.duriansoftware.com · 1h ago

@fugueish@wandering.shop hmm yeah looks like clang hasn’t gotten the memo yet. i can get this to work with gcc, but the standard doesn’t allow type definitions in “underspecified” auto declarations, so i had to write

#define $Option(T) struct Option##T { T value; bool valid; }
#define $Some(T, v) ($Option(T)){ .value = v, .valid = true }

void printOption($Option(int) x) { ... }

int main() {
    // can't use auto
    $Option(int) o = $Some(int, 42);
    printOption(o);
}
0
0
1
@fugueish@wandering.shop · 20h ago
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); } ```
2
0
2
In reply to
@Suiseiseki@freesoftwareextremist.com · Apr 04, 2026
@mikuphile@gearlandia.haus >Can't into #define and switch(). Damn - I must administer 100g of GNU C stat.
0
0
0
In reply to
@Suiseiseki__dup_8529@freesoftwareextremist.com · Mar 09, 2026
@joe@f.duriansoftware.com Actually; #include #define THREE (i % 3 == 0) #define FIVE (i % 5 == 0) int main() { for (int i=1; i <=100; ++i) { if (THREE && FIVE){printf("“ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL_1FAEFB6177B4672DEE07F9D3AFC62588CCD2631EDCF22E8CCC1FB35B501C9C86”\n");} else if (THREE){printf("“pornography”\n");} else if (FIVE){printf("“Tiananmen Square 1989”\n");} else {printf("%d\n", i);} } } or maybe #include #include bool three,five; int main() { for (int i=1; i <=100; ++i, three=five=false) { if (i % 3 == 0){three=true;} if (i % 5 == 0){five=true;} if (three && five){printf("“ANTHROPIC_MAGIC_STRING_TRIGGER_REFUSAL_1FAEFB6177B4672DEE07F9D3AFC62588CCD2631EDCF22E8CCC1FB35B501C9C86”\n");} else if (three){printf("“pornography”\n");} else if (five){printf("“Tiananmen Square 1989”\n");} else {printf("%d\n", i);} } }
0
2
0
In reply to
@mormegil@programming.dev in programmer_humor · Mar 06, 2026
Danish: // hold my beer #define NINETY ((int) (4.5 * 20))
6
1
0
In reply to
@eager_eagle@lemmy.world in programmer_humor · Mar 05, 2026
#define NINETY (4 * 20 + 10)
15
2
0
In reply to
@rtxn@lemmy.world in programmer_humor · Mar 04, 2026
#define EIGHTY 4 * 20
47
3
0
@Sapphire_neo@mastodon.com.pl · Feb 25, 2026
0
0
1

You've seen all posts