#include

13 posts · Last used 15d

Back to Timeline
thephd
@thephd@pony.social · May 02, 2026
It's live. https://godbolt.org/z/71f3xxcYh #include #define bar(x) _Generic(x, \ int v: v, \ struct foo v: v.name \ ) struct foo { char* name; }; int main() { struct foo f = { "test" }; bar(3); bar(f) = "something"; puts(f.name); // prints "something" }
44
26
24
tankgrrl
@tankgrrl@hachyderm.io · Apr 30, 2026
No warranty implied, use at your own risk. But this short C program can check if your Linux machine is still vulnerable to Copy Fail (there's also this page with python code from our friends in Estonia https://docs.hpc.ut.ee/public/cve-2026-31431/ ) Output includes "ARE available" or "NOT available" Again: compile and run at your own risk. Don't just trust me blindly. Read the code. #CopyFail #CVE-2026-31431 ============== #include #include #include #include #include #include int main(void) { int sock; struct sockaddr_alg sa; // Prepare sockaddr_alg for AEAD/GCM memset(&sa, 0, sizeof(sa)); sa.salg_family = AF_ALG; strcpy((char *)sa.salg_type, "aead"); strcpy((char *)sa.salg_name, "gcm(aes)"); // Try to create AF_ALG socket sock = socket(AF_ALG, SOCK_SEQPACKET, 0); if (sock == -1) { perror("socket(AF_ALG, aead)"); printf("algif_aead functions are NOT available (AF_ALG socket creation failed).\n"); return 1; } // Try to bind to AEAD/GCM if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) == -1) { perror("bind(AF_ALG, aead, gcm(aes))"); printf("algif_aead functions are NOT available (bind failed).\n"); close(sock); return 1; } printf("algif_aead functions ARE available (AF_ALG AEAD bind succeeded).\n"); close(sock); return 0; }
3
3
0
rmi
@rmi@cloudisland.nz · Apr 30, 2026
#include “goblins.h”
1
0
0
In reply to
kasdeya
@kasdeya@cryptid.cafe · Apr 28, 2026
formatting and printing values in C++ seems nice and normal and not insane at all 🙃 #include #include using namespace std; int main() { cout << fixed << showpoint << setprecision(2) << setw(9) << 34.789 << endl; cout << fixed << showpoint << setprecision(3) << setw(5) << 7.0 << endl; cout << fixed << noshowpoint << 5.789e12 << endl; cout << left << setw(7) << 67 << endl; }
5
13
0
fugueish
@fugueish@wandering.shop · Apr 26, 2026
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
3
2
lcamtuf
@lcamtuf@infosec.exchange · Apr 25, 2026
You know what would be good? If C/C++ supported remote includes, like so: #include
16
1
6
In reply to
JdeBP
@JdeBP@mastodonapp.uk · Apr 23, 2026
@jperkin@federate.me.uk Retaining that uniform, clean, system involves adding the stuff that's needed for more modern C++ anyway into the right iso/math_iso.h header. If I were doing that, head/iso/math_iso.h would gain something like template inline typename __illumos::__enable_if<__illumos::__is_integral<_T>::__value, double>::__type log(_T __v) { return log(static_cast(__v)); } inside namespace std, and #include at the top. There'd be an head/iso/type_traits.h with the well-known implementation of enable_if<> as __illumos::__enable_if<> and a suitable implementation of __illumos::__is_integral<> instantiated as appropriate. #CPlusPlus #gcc #clang #Illumos
0
3
0
In reply to
phnt
@phnt@fluffytail.org · Apr 20, 2026
@SuperDicq@minidisc.tokyo @fiore@brain.worm.pink @reia@linfan.moe It is ugly and inconsistent which leads to more brain processing needed to parse something as simple as indentation. The half-indentation also fucks with my brain way too much since I like 1 tab/8 spaces for indentation. Like look at this monstrosity #include int main (void) { int i = 1; if (i == 1) { printf ("Hello world!\n"); return 0; } else if (i != 1) { printf ("unreachable\n"); return 1; } }
2
8
0
In reply to
Suiseiseki__dup_8529
@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);} } }
3
6
0
In reply to
Suiseiseki__dup_8529
@Suiseiseki__dup_8529@freesoftwareextremist.com · Mar 09, 2026
@joe@f.duriansoftware.com #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);} } }
4
2
0
In reply to
Suiseiseki__dup_8529
@Suiseiseki__dup_8529@freesoftwareextremist.com · Feb 27, 2026
@reiddragon@fedi.catto.garden Uninitialized variables in a C function are undefined behavior - the compiler can decide to zero the variable, or leave it uninitialized - whichever seems faster - so you should always initialize a variable before using the value. Variables are only guaranteed to get zerod if those are global variables, like; #include int x; int main(){ But that's not a good habit to get into - it's better to always initialize variables.
0
1
0
In reply to
Suiseiseki__dup_8529
@Suiseiseki__dup_8529@freesoftwareextremist.com · Feb 23, 2026
@yonle@fedinet.waltuh.cyou That's a lot of syntax - a lot more typing than GNU C; #include int main() { const char *str = "a string"; printf("%c\n", str[0]); printf("0x%x\n", str[sizeof(str)]); printf("%c\n", str[sizeof(str)-1]); }
1
1
0
SuperDicq__dup_474
@SuperDicq__dup_474@minidisc.tokyo · Nov 24, 2025
@whirly@netzsphaere.xyz I have abs. #include int foo = abs(-67);
0
1
0

You've seen all posts