#include

26 posts · Last used 5d

Back to Timeline
jade arson. @awoo@gts.apicrim.es · Aug 04, 2026
Boosted by Furbland's Very Family-Friendly Account™ @GroupNebula563@mastodon.social
i love that one could just follow #include and #define to stumble across some funny C code every once in a while lol
0
0
1
5225225 @5225225@furry.engineer · Aug 04, 2026
Boosted by Furbland's Very Family-Friendly Account™ @GroupNebula563@mastodon.social
Lately you’ve posted about #include. Add these as featured hashtags?
2
0
5
SirWumpus 🍁⚔️ 🛡️ @sirwumpus@tilde.zone · Aug 04, 2026
Replying to @charette@mstdn.ca
@charette@mstdn.ca Only if you #include , see C17 section 7.9 Alternative spellings . Section A.1.2 Keywords does not list them.
0
1
0
root42 @root42@chaos.social · Jul 29, 2026

Quick, without validating through a compiler, or thinking too long: what does this C program do? #include <stdio.h> int main(void) { printf('A'); return 0; } #letscode

Print the character A, then quit
32.2% (29)
Crash
27.8% (25)
Compute the value of Pi
1.1% (1)
It depends...
38.9% (35)
90 votes Poll closed
View on chaos.social
0
1
1
Alex Celeste, Princess Consort of Burnout @erisceleste@tech.lgbt · May 19, 2026
Replying to @SRAZKVT@tech.lgbt
@SRAZKVT@tech.lgbt well, you get into interesting library design philosophy questions there a well-designed library interface for any feature shouldn't leave the user needing to think about how its macros expand any more than they usually should think about what lies behind a function call boundary - which is a non-zero amount of the time but it is comparatively very low (obviously anything built with #include INCREMENT failed hard at the first hurdle but ygwim) @eniko@mastodon.gamedev.place
1
1
0
mos_8502 :verified: 🇨🇦 @mos_8502@studio8502.ca · Jul 16, 2026
Replying to @mos_8502@studio8502.ca
What I do is, I have main.c which (obviously) contains the main() function, but it also contains static functions setup() and quit(), which, respectively, handle setting up the initial program state and cleaning up anything that needs cleaning up before exit. Generally, my main.c looks something like this: #include "foo.h" static void quit() { } static void setup() { } int main(int argc, char **argv) { setup(); // In a GUI program, this is where I'd enter the main loop quit(); }
1
1
0
Noisytoot @noisytoot@berkeley.edu.pl · Jul 15, 2026
Replying to @pastthepixels@is.potatoe.ca
@pastthepixels@is.potatoe.ca @kemona_halftau@sharkey.skydevs.me testing using this program: #include #include int main(void) { pid_t pid = fork(); switch (pid) { case -1: perror("fork"); return 1; case 0: // child printf("child\n"); for (;;) pause(); default: // parent printf("parent, child PID = %d\n", pid); return 0; } } the child process does not get killed when the parent terminates. on linux, you can set the signal child processes receive when the parent dies using prctl(PR_SET_PDEATHSIG, …), but by default the child processes do not get killed when the parent dies
0
0
0
Alice :neocat_flag_transbian: @alice@mk.nyaa.place · Sep 16, 2025
Replying to @alice@mk.nyaa.place
I implemented #include for shaders. While in theory I could make use of ARB_shading_language_include, the problem is I have to list those includes ahead of time, meaning that I have to parse the file and look for the includes... then load those and look there as well, etc. So... I decided to just implement my own tiny preprocessor - just expanding includes and doing nothing else. It's fairly janky - e.g. this: /* #include "something.inc" */ where something.inc is: */ blah /* will fail. But - oh well.
0
1
0
historicaldocuments @historicaldocuments@lemmy.world · Jun 09, 2026
Replying to @SinTan1729@programming.dev
Try the c++23 standard. There’s been a lot of cross pollination. Contrived example follows: #include #include #include #include int main(int argc, char *argv[]) { double pi = std::numbers::pi; std::string fstr = std::format("{}, {:>.2}, {:>.5}, {:>.10}", pi, pi, pi, pi); std::string h = "Hello"; std::string w = "World"; std::println("{}, {}!", h, w); std::print("This won't have a {},", "newline"); std::println(" but this will add it."); // Add a newline. // Can't put a non-constant string as the first argument to // print or println so they can be checked at compile time. std::println("{}", fstr); return EXIT_SUCCESS; }
0
0
0
Joe Groff @joe@f.duriansoftware.com · Jun 05, 2026
Replying to on mastodon.social

@Gte@mastodon.social i would #include <8647.h> if i could

0
0
0
Don't forget to stay hydrated.🍉🍉🍉🍉🍉 @testaccount789@sh.itjust.works · May 21, 2026
Replying to @lukstru@piefed.social
I tested it, it works as it is. #include #include void main(){ bool true_or_false = true; if(true_or_false){ goto if_true; } printf("This code runs only if false.\n"); goto end_false_if; if_true: printf("This code runs only if true.\n"); end_false_if: printf("This code always runs.\n"); } If true, it jumps to if_true, then runs other code. If false, the if gets skipped, if false code gets run, then it skips over if true code.
2
1
0
Björkus "No time_t to Die" Dorkus @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
38
24
💀 𝓕airchild 💀 @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
kasdeya @kasdeya@cryptid.cafe · Apr 28, 2026
Replying to @kasdeya@cryptid.cafe
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
Chris Palmer @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 :verified: :verified: :verified: @lcamtuf@infosec.exchange · Apr 25, 2026
You know what would be good? If C/C++ supported remote includes, like so: #include
16
1
6
JdeBP @JdeBP@mastodonapp.uk · Apr 23, 2026
Replying to @JdeBP@mastodonapp.uk
@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