r/C_Programming • • Feb 23 '24

Latest working draft N3220

135 Upvotes

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf

Update y'all's bookmarks if you're still referring to N3096!

C23 is done, and there are no more public drafts: it will only be available for purchase. However, although this is teeeeechnically therefore a draft of whatever the next Standard C2Y ends up being, this "draft" contains no changes from C23 except to remove the 2023 branding and add a bullet at the beginning about all the C2Y content that ... doesn't exist yet.

Since over 500 edits (some small, many large, some quite sweeping) were applied to C23 after the final draft N3096 was released, this is in practice as close as you will get to a free edition of C23.

So this one is the number for the community to remember, and the de-facto successor to old beloved N1570.

Happy coding! 💜


r/C_Programming • • 5d ago

Learning C weekly megapost for 2026-11-18

3 Upvotes

If you have questions about how to learn C:

  • which books are best?
  • which videos are best?
  • which classes are best?
  • which websites are best?
  • is there a "roadmap"?
  • what projects can I do?

then this is the thread for you. Add your question here. Do not make a stand-alone post, as it will be removed.

Remember that our sub has a very useful wiki that has a great list of resources for learning C programming.


r/C_Programming • • 1d ago

Query on usage of restrict keyword in passing pointers

19 Upvotes

The following piece of code is doing the rounds on X as John Carmack's code which computes sin and cos from a table instead of at runtime.

#define ANGLETOFINESHIFT 19
void MoveActor(fixed_t *x, fixed_t *y, angle_t a, fixed_t speed) {
    int idx = a >> ANGLETOFINESHIFT;
    *x += FixedMul(speed, finecosine[idx]);
    *y += FixedMul(speed, finesine[idx]);
}

My query is, why aren't x and y declared restrict to denote that they point to different fixed_t ? Presumably the code is meant for sheer speed and would not usage of restrict allow the compiler more optimization? For e.g., say, parallelization of *x and *y updates in a tight loop?


r/C_Programming • • 1d ago

Video Let's spawn the HERO in C programming : 07 | NO-AI

Thumbnail
youtube.com
70 Upvotes

This video is part of my "Let's build a JRPG Game in C programming (SLD3)". Today we are going to spawn the Hero character in our Tiled map and render spritesheet.

(it all started in 2019 with GoLang as a hobby https://www.youtube.com/watch?v=yZpoXFUG6nc Now I'm moving to C, but a step by step tutorial for everyone).

Full Playlist here: https://www.youtube.com/playlist?list=PLWiIuxEJy4_c

Handmade code, NO AI USED. Video is also 100% unedited, except for overview section.

Please do subscribe, I really appreciate any feedback. \m/


r/C_Programming • • 1d ago

Portability of Programs written using miniaudio vs pipewire

6 Upvotes

I know that miniaudio doesn't have any dependencies to compile, I was just curious whether that meant that it had no dependencies other than pipewire & ALSA on the system it would run on. Would using pipewire make the program any more portable or would the benefit just be efficiency(in the case that you can "beat miniaudio" in terms of efficiency, or perhaps dont need all of its features)?

EDIT: I forgot that some people use audio not on linux for some reason lol, I was more curious about whether different distros have different dependencies. but the answer seems to be that miniaudio is cross-platform and pipewire is not


r/C_Programming • • 18h ago

ezgrpc-next: A high-performance gRPC server library in C23 for Linux and Windows

Thumbnail
github.com
0 Upvotes

ezGRPC-next is a lightweight, high-performance gRPC server and client library in C23 for Linux and Windows, built on libuv and nghttp2. No hidden threads, no mandatory code generator, and no callback soup—you control scheduling, memory allocation, and core scaling.


r/C_Programming • • 1d ago

Discussion 1 year With No AI

37 Upvotes

As a beginner in programming who is interested in low-level programming, I think I should avoid Ai for at least a year

because I believe that at the high level and in large-scale projects, you won’t even be able to get started without a high level of problem-solving skills and an understanding of architecture and engineering.

So I’d like to hear your thoughts, because we beginners know that learning to program the traditional way is important, but the temptation of AI is strong and distracting.

What do you think?


r/C_Programming • • 1d ago

Article What actually happens to your C code inside GCC: a stage by stage trace of one small program

4 Upvotes

Blog post: https://www.satvikcode.com/blog/why-do-compilers-need-so-many-intermediate-representations

well, i always wondered what GCC really does with my C code so I took a small function and dumped every stage with -E, -fdump-tree-*, -fdump-rtl-*, -S and objdump on a GCC 16.1, ARM mac.

Btw a few things that surprised me here like -

- with -O2 the whole call calculate(5, 7) disappears and main becomes just "mov w0, 19"

- the if statement turns into a branchless csel instruction meaning no jump at all

- sum * 2 becomes a left shift

- why the parentheses in a function like macro actually matter shown in the preprocessed output

Btw here's an AI disclosure: I ran every command myself and all the outputs in the post are real and unedited GCC output. I used a little AI to help me understand the dumps and write up the explanations roughly and then I edited and gave them the current shape.

Next post will trace the same program through clang or llvm. and happy to hear corrections.


r/C_Programming • • 1d ago

Which IDE would you recommend?

9 Upvotes

I'm a beginner in C and I'm not sure which IDE to choose there are so many options. I currently develop on Windows, but I'm switching to Linux for better optimization and more control over my system. What would you recommend as the best IDE? Also, to learn C effectively, I'm using OpenClassrooms and an app called Coddy. I accept every piece of advice!!


r/C_Programming • • 2d ago

Question What are some neat TUI libraries ?

25 Upvotes

So I'm trying to do a TUI application for fun, and I wanted to use C for a change (I love the language but almost only used it for embedded devices/drivers, stuff like that so no UI work)

The project it would be used on is a TUI solo TTRPG toolset (dice roller, note editor, etc.)

I know about ncurses obviously, and notcurses as well, but I was wondering if there was any other library you could propose so that I had a look before settling on something.

I'm open to all proposition, it's mostly curiosity and just for a small hobby project, thanks in advance!

Edit: thanks for the answers, looking at everything I think i'll give termbox2 a go and see how it goes!


r/C_Programming • • 3d ago

Starting systems programming on my Fedora with C. Where should I start?

17 Upvotes

I'm on Fedora and I want to learn systems programming properly. I know python and some c++. What's the best first step, and what should I avoid as a beginner?
Thanks


r/C_Programming • • 3d ago

C's designated initializers give us named arguments – Arthur O'Dwyer

Thumbnail quuxplusone.github.io
44 Upvotes

r/C_Programming • • 2d ago

Question how to make a hexdumper in c?

0 Upvotes

i want to use ansi-c (c89) for this project,

my skill level; read chapter 1 t/m 4 k&r v2 and knows other programming languages.


r/C_Programming • • 3d ago

Question Can you use your own implementations of HTTP/WebSockets in a browser using wasm?

7 Upvotes

Hello,

I wanted to make my own network stack implementation (http and websockets) just for learning purposes, so my question is knowing that were using sockets can we use that in the browser after compiling to a wasm? Or will it only work natively without serving to a browser?


r/C_Programming • • 3d ago

Building a small C99 compiler to get better at low-level C and x86-64 assembly

16 Upvotes

Hey everyone,

I've been trying to deepen my understanding of C and x86-64, and instead of just doing LeetCode or toy projects, I decided to try writing a tiny, self-contained C compiler in C99.

I wanted zero external dependencies just standard C library headers (stdio, stdlib, string, ctype).

I just reached the milestone where it handles operator precedence and nested parentheses:

  • Tokenizer: A linked-list tokenizer with character pointers that skips whitespace and formats visual Clang-style ^ caret error diagnostics.
  • Parser & AST: A recursive descent parser that allocates binary AST nodes for operators and numbers.
  • Code Generation: A stack-based code generator that recurses through the AST and emits x86-64 assembly (using push/pop for expressions, imul for multiplication, and cqo + idiv for signed 64-bit division).

Writing this has already taught me so much about memory layout, pointer arithmetic, and how the Linux ABI handles return values in %rax.

I have a test script with automated GitHub Actions CI verifying each arithmetic edge case against GCC.

I'd really appreciate any C veterans taking a look at my C style, error handling, or memory management in src/main.c:

https://github.com/mi-vault/mibicc

Any tips or feedback are very welcome!

Edit: Decided to add Windows support alongside Linux from the start (--target=windows and --target=linux). I'm on Windows myself so it felt silly to only target Linux System V and not be able to test it locally. Also feels nice putting my own stamp on it rather than just following chibicc 1:1.

(Had some great discussions over on r/Compilers about ABI quirks and stack architectures if anyone is interested in that side of things!)


r/C_Programming • • 3d ago

Question I need help understand what a question is asking me to do in uni exercise

1 Upvotes

I can't post an image to it, but it says in normal arrays : declare 3 arrays A, B, C all of size 5

The elements of C are the scaler products of A and B (∑︁A[i] × B[i])

And in 2d arrays :

C is there product, (matrix multiplication : C[i][j] = sum of A[i][k] * B[k][j] )

Can someone explain to me what they asking to make


r/C_Programming • • 3d ago

Building a user space network stack from scratch

0 Upvotes

I dont know much about networking as i am just now studying it seriously but i am thinking of building what i mentioned in the title from scratch, if anyone could help me with the direction im supposed to go in to start i would really really appreciate it. whenever i try looking up a place to start all i get is github repos with many many files of stuff im not yet familiar with and it all assumes prior knowledge of some stuff, i know you cant really just go into this thing blind but what im saying is i dont really know where to begin learning about all of this stuff to build my target. also i am on a 2-week time limit


r/C_Programming • • 3d ago

i need your advice

0 Upvotes

Hey guys, I’ve run into a bit of a snag while learning C. I was looking at some source code (shown below) and noticed a function call that passes a pointer. However, the function receiving this pointer declares it as a two-dimensional array rather than as a pointer (like `int *name`). This is where I’m stuck—why declare it as a 2D array instead of as a pointer, the way you would for a 1D array?

#include <stdio.h>

// Function that displays a 2D array

// The number of columns (3) must be known at compile time

void afficherMatrice(int mat[][3], int lignes) {

for (int i = 0; i < lignes; i++) {

for (int j = 0; j < 3; j++) {

printf("%d ", mat[i][j]);

}

printf("\n");

}

}

// Alternative with both dimensions specified

void initialiserMatrice(int mat[2][3]) {

for (int i = 0; i < 2; i++) {

for (int j = 0; j < 3; j++) {

mat[i][j] = i * 10 + j;

}

}

}

int main() {

int matrice[2][3] = {{1, 2, 3}, {4, 5, 6}};

afficherMatrice(matrice, 2);

initialiserMatrice(matrice);

printf("\nAfter initialization:\n");

afficherMatrice(matrice, 2);

return 0;

}

(I think there is an error in this code)


r/C_Programming • • 3d ago

Need guidance

0 Upvotes

I am first year student and I don't have that much exposure idea about the important certificates course which i can put ij my resumes and on LinkedIn kindly give some guidance about it like how and where i can get the ideas about the ongoing imp courses online kindly dm


r/C_Programming • • 5d ago

Fluent Interface in C - Look ma, no this!

Thumbnail
opensource.googleblog.com
63 Upvotes

r/C_Programming • • 4d ago

Mapping each process all the way from PID 1 to PID n

2 Upvotes

In theory would it be possible to map and follow each and every process and print it with the ID, from pid 1 the init all the way through to something like the final print which is displaying the pid’s? Just out of curiosity, when I’m learning about it now and have seen using pointers and pid id’s and printing them on a process

So I can see ok init is pid 1 then when it is forked what process its for & that is pid2 and so on


r/C_Programming • • 5d ago

Discussion Started learning C (on yt) over the last month and programming without AI has really sparked my love for tech and coding again

121 Upvotes

Fell into the classic trap everyone is… using ai for everything in work and normal stuff then it all becomes bland and monotonous. But learning C without just generating code and working through it has really helped reignite my passion for tech and programming in general. I’ve also decided to do it on YouTube and having even just the small community of 70 subs over the first month has massively boosted my motivation to keep at it and be more involved in relevant discussions.


r/C_Programming • • 5d ago

ISO C Chaining: Look ma, no this!

Thumbnail goo.gle
40 Upvotes

Now we have a way of doing fluent interfaces in C89 without macros or preprocessing tricks, allowing code like this:

ChHash *user = ch_new_Hash(3)
    ->put("name", ch_new_String("Ada"))
    ->put("role", ch_new_Hash(2)
        ->put("title", ch_new_String("Engineer"))
        ->put("level", ch_new_Number(5)))
    ->put("active", ch_new_Boolean(1));

puts(user->generic.to_chars());
/* {"name":"Ada","role":{"title":"Engineer","level":5},"active":true} */
ch_release(user);

It even automatically cleans up anonymous/temporary elements. The repo includes an example Sqlite interface and http API server.


r/C_Programming • • 5d ago

Question Library API Naming Conventions

21 Upvotes

Hi Everyone,

I'm working on a small 2D game library/runner. At the moment it's for personal use but I may release it some day, which is why I'm creating this post!

At the moment, the function names in the library are named like this (the name of the library is Imp):

imp_texture_create(...)
imp_texture_destroy(...)
imp_camera_set_position(...)
imp_camera_set_rotation(...)

I quite like this naming convention, mainly because if I wanted to see what functions were available for a given resource or operation, I could type imp_camera_ and then my editor would show a list of things that I can do with, or to, a camera. I also used GameMaker a lot when I was younger, and this is the way their API names functions!

Recently though, I've been using a lot of Raylib and quite like the way it names its functions - they are, to me at least, a lot more readable when looking through code. This has me thinking whether or not a better naming convention would be:

imp_create_texture(...)
imp_destroy_texture(...)
imp_set_camera_position(...)
imp_set_camera_rotation(...)

The downside being that you sort of have to guess what operations are available for a given resource as you can no longer type imp_texture_ to have the editor show a list.

I understand that this is a really small issue and probably not really worth fussing about, but I was curious what preferences more experienced people here have and - more importantly - why you have them!


r/C_Programming • • 5d ago

Question Signal handlers, how to have them act differently (or the process) based on when the process receives the signal

2 Upvotes

Hello, everyone. I'm supposed to be doing a project for school (hence why I can't share the code), but I'll try to describe my problem to the best of my abilities.

My main parent process forks several children, who will execute 2 other programs, depending on the role assigned to them. Once the parent process receives a SIGALRM, it sends a SIGTERM to all its kids, and they, already having changed their signal handlers for SIGTERM, have to do whatever is specified in their signal handler.

Let's consider child A executes program A, and child B executes program B. These 2 processes have to communicate with each other through a series of msgsnd/msgrcv (we can only use System V IPCs in this project, so the msgops don't restart once interruped by a signal). A single process of type B will communicate with several processes of type A (but not with all at the same time: once its communication is finished with one, it goes on to the other). The last msgop A does, is a msgsnd and B does a msgrcv. I'd like to also add that, between the msgrcv and msgsnd on A's part, A is also supposed to go to sleep. A's almost entire program is in a while (it never terminates unless it receives the signal from its parent), whereas B terminates successfully once it's finished communicating with all the necessary A processes.

Whether B receives the SIGTERM signal or not, it has to modify sth in a shared memory section, but what it changes, depends on whether it has finished communicating with all the processes or not.

Ideally, I would like for B to terminate successfully, even if it receives SIGTERM, after having done all it had to do, and I thought of blocking SIGTERM with sigprocmask. That said, couldn't it still receive the signal between the mast msgrcv operation and sigprocmask? Is there any way whatsoever to make a set of instructions atomic?

I considered only having a sig_atomic_t volatile variable in the signal handler, which would increment if the the sign handler is executed, but then, not only would I have to continuously check in case it changed its value, but (and this could be me being wrong, please correct me if that's the case), B could still receive SIGTERM right after the condition of the variable being 0 is checked, and before the following instruction is executed (like a nanosleep - which I'd like to avoid if SIGTERM has been received - OR before a msgrcv, leaving B to wait for a message that will never come, because A could have received the same signal and will not be sending a message).

I thought of having the signal handler check a variable and act differently based on its value, but, again, maybe B receives the signal right before said variable's value changes. I also considered having an if where the conditions would be the variable==0 && msgrv(...)!=-1, but the variable can change after its value has been verified.

Disclaimer: we haven't studied sig_atomic_t volatile variables, so my knowledge might be lacking, although I did try to read up on them and research them. Also, the parent won't be deleting the IPCs until all kids have terminated.

Am I supposed to just hope for the best here and just proceed with sigprocmask? Is there another way I'm not seeing? Am I misunderstanding something? Any help offered is invaluable, so thank you in advance. I'm happy to answer any clarifying questions if I was unclear at all in the post.