#include

30 posts · Last used 9d

Replying to
@neal@social.gompa.me @ND3JR@social.coop @trashheap@tech.lgbt Let us not define a standard for getting keyboard scan codes and then blame the compositors when every single one of them does "#include ". Including the reference compositor.
0
3
0
0
Replying to
@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
0
Quick, without validating through a compiler, or thinking too long: what does this C program do? #include int main(void) { printf('A'); return 0; } #letscode

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%
Crash 28%
Compute the value of Pi 1%
It depends... 39%

90 people · Closed

2
2
1
0
Replying to
@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
0
Replying to
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
0
Replying to
@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
0
Replying to
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
137
0
0
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
0
Replying to
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
0
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
0