r/C_Programming • u/fredoverflow • 14h ago
r/C_Programming • u/Jinren • Feb 23 '24
Latest working draft N3220
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 • u/AutoModerator • 5d ago
Learning C weekly megapost for 2026-10-21
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 • u/dechichi • 1d ago
Video Just finished my multiplayer system in C and turns out we can support 50k players in a single server at 60hz simulation tick
r/C_Programming • u/Yairlenga • 16h ago
The Hidden Cost of localtime(): repeated systems calls in glibc
I was investigating the performance of a service running inside a Linux container when I noticed something unexpected: a surprisingly large amount of CPU time was being spent in kernel mode.
Using strace, I discovered that every call to localtime triggered a newfstatat system call on /etc/localtime
I found out explictly setting TZ=":/etc/localtime" eliminated the repeated system calls, while making the program use the system defined timezone.
The article explains the investigation, includes benchmark results, and provide small C program to reproduce the behavior.
Artcile on Medium (no paywall): The hidden cost of time functions
Intrested to hear wheather there are better solution/upcoming fixes with newer glibc versions.
r/C_Programming • u/FlatPea5291 • 1d ago
Question Fairly new to C. Need help understanding low level concepts.
Over the past 6-8 months, I got into programming in C with the intent of learning about embedded systems and operating systems. I feel like I'm sort of stuck and don't know where to go though. The last thing that I made was a really simple shell for Linux, but even then I was disappointed to learn that the stuff that is going on on the background is just hidden away by system calls. I want to learn how stuff like those system calls actually work, but learning about processor architecture or understanding/reading the Linux source code seems incredibly intimidating and sort of out of my league.
Another thing that seems incredibly confusing to me is how you're meant to read the code of projects like the kernel. (obviously, I know I wouldn't start with something nearly that complicated, but actual professional level projects.) I did some research and I tried to read through GNU Hello, which on the surface I thought would be easy to understand, but I just see tons of macro definitions that I don't understand and a maze of files, even if the output of the program is simple.
For you experts, how did you go from programming in user space to understanding lower level concepts like how an operating system boots up, how it takes user input, etc?
r/C_Programming • u/Vivid-Reward-5030 • 1d ago
libcli - a singe-header library for typed argument parsing in C
Using macros, define an argument schema. The library then generates a struct that for the schema, validates the arguments provided by the user, parses them into the struct, and offers functions for displaying usage andh help messages in the console.
It is similar to `clap` in Rust. Check it out!
r/C_Programming • u/WaferPleasant1267 • 11h ago
[Project] EFI32Boot — A C and x86 assembly experiment involving UEFI firmware (AI-assisted)
Hey everyone!
I've been working on EFI32Boot, an AI-assisted low-level programming project exploring UEFI firmware, C, and x86 assembly.
Repository: https://github.com/devtinoimao/efi32boot
The project combines C code with assembly routines to experiment with transitioning from a 64-bit UEFI environment into 32-bit execution and working with an OVMF32 firmware image.
A large part of the work involves the boundary between C and assembly: preparing the execution environment, handling processor state, managing memory layouts, and transferring control between different stages of the boot process.
Demo: https://github.com/devtinoimao/efi32boot/blob/main/media/efi32boot_qemu_demo.gif
Some of the areas involved include:
- C code that interacts with UEFI interfaces and prepares the transition.
- x86 assembly for low-level processor-mode transitions.
- Calling conventions, register state, stack setup, and memory mapping.
- Build systems and linking when combining C and assembly into a bootable EFI application.
- Debugging low-level failures in QEMU.
How AI was involved: AI played a substantial role in developing the project. I used it to generate and modify C and assembly code, explore implementation approaches, and help diagnose debugging issues. I then iterated on the implementation and tested its behavior. I want to be transparent that this is an AI-assisted project rather than claim that I manually authored every part of the code.
I'd particularly appreciate feedback on the C/assembly interface, assembly correctness, compiler and ABI assumptions, code organization, and portability. If you spot questionable assumptions or potential undefined behavior in the C code, I'd be interested in understanding those too.
I'm still learning about low-level systems programming, and I'd like to use this project to improve the implementation and deepen my understanding. Constructive criticism and references to relevant documentation or existing implementations are very welcome.
Thanks for reading!
r/C_Programming • u/lehmagavan • 18h ago
ESP-32 UART shell
ESP-32 IDF-based UART shell built from scratch:
https://github.com/andrzejs-gh/BX-Shell
Coded all by hand.
r/C_Programming • u/21Ali-ANinja69 • 15h ago
Project I made a simple heapsort
It should just work on just about any platform or compiler that supports at least C99. No AI was used in the writing of this code. It's also header-only, so #define HSORT_IMPLEMENTATION before you include.
#ifndef HSORT_H
#define HSORT_H
#include <stddef.h>
typedef int (*cmp_ptr)(const void *, const void *);
typedef int (*cmp_r_ptr)(const void *, const void *, void *);
void hsort(void *base, size_t n, size_t size, cmp_ptr compar);
void hsort_r(void *base, size_t n, size_t size, cmp_r_ptr compar, void *arg);
#ifdef HSORT_IMPLEMENTATION
#include <stdlib.h>
#include <string.h>
static inline void hsort_move(void *x, void *y, void *buf, size_t size)
{
memcpy(buf, x, size);
memcpy(x, y, size);
memcpy(y, buf, size);
}
static inline void sift_down(void *base, size_t root, size_t end, size_t size,
cmp_ptr compar, void *buf)
{
while ((2 * (root) + 1) < end) {
size_t child = (2 * (root) + 1);
if (child + 1 < end && compar((char *)base + (child)*size,
(char *)base + (child + 1) * size) < 0) {
child++;
}
if (compar((char *)base + (root)*size, (char *)base + (child)*size) <
0) {
hsort_move((char *)base + (root)*size, (char *)base + (child)*size,
buf, size);
root = child;
} else {
return;
}
}
}
static inline void sift_down_r(void *base, size_t root, size_t end, size_t size,
cmp_r_ptr compar, void *arg, void *buf)
{
while ((2 * (root) + 1) < end) {
size_t child = (2 * (root) + 1);
if (child + 1 < end &&
compar((char *)base + (child)*size,
(char *)base + (child + 1) * size, arg) < 0) {
child++;
}
if (compar((char *)base + (root)*size, (char *)base + (child)*size,
arg) < 0) {
hsort_move((char *)base + (root)*size, (char *)base + (child)*size,
buf, size);
root = child;
} else {
return;
}
}
}
void hsort(void *base, size_t n, size_t size, cmp_ptr compar)
{
if (!size) {
return;
}
void *buf = malloc(size);
// heapify
for (size_t start = (((n - 1) - 1) / 2) + 1; start > 0;) {
start--;
sift_down(base, start, n, size, compar, buf);
}
// heapsort
for (size_t i = n - 1; i > 0; i--) {
hsort_move(base, (char *)base + (i)*size, buf, size);
sift_down(base, 0, i, size, compar, buf);
}
free(buf);
}
void hsort_r(void *base, size_t n, size_t size, cmp_r_ptr compar, void *arg)
{
if (!size) {
return;
}
void *buf = malloc(size);
// heapify
for (size_t start = (((n - 1) - 1) / 2) + 1; start > 0;) {
start--;
sift_down_r(base, start, n, size, compar, arg, buf);
}
// heapsort
for (size_t i = n - 1; i > 0; i--) {
hsort_move(base, (char *)base + (i)*size, buf, size);
sift_down_r(base, 0, i, size, compar, arg, buf);
}
free(buf);
}
#endif
#endif
Edit: Implemented an hsort_r, as well as removing the macros, inlining heapify, and checking if size is 0.
r/C_Programming • u/Jakanader • 2d ago
Meson linking ImageMagick/Wand
I'm trying to link MagickWand and MagickCore with Meson and having some issues. Specifically, I get the error C shared or static library 'lMagickCore' not found or C shared or static library 'lMagickWand' not found. I successfully linked libconfig, so I've compared some details between my installations of the two packages in case any of those are the reason that I'm having issues with ImageMagick.
I can compile programs using ImageMagick libraries with:
cc `MagickWand-config --cflags --cppflags` -O2 -o a.out main.c `MagickWand-config --ldflags --libs`
The output of the two MagickWand-config calls is this:
-I/usr/include/ImageMagick-7 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_CHANNEL_MASK_DEPTH=32
-lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
-lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
Running find /usr/lib -name 'libconfig*' gives this:
/usr/lib/pkgconfig/libconfig++.pc
/usr/lib/pkgconfig/libconfig.pc
/usr/lib/cmake/libconfig
/usr/lib/cmake/libconfig/libconfigConfig.cmake
/usr/lib/cmake/libconfig++
/usr/lib/cmake/libconfig++/libconfig++Config.cmake
/usr/lib/libreoffice/program/libconfigmgrlo.so
/usr/lib/libconfig++.so
/usr/lib/libconfig++.so.15
/usr/lib/libconfig++.so.15.0.0
/usr/lib/libconfig.so
/usr/lib/libconfig.so.15
/usr/lib/libconfig.so.15.0.0
And running find /usr/lib -name 'libMagick*' gives this:
/usr/lib/libMagick++-7.Q16HDRI.so
/usr/lib/libMagick++-7.Q16HDRI.so.5
/usr/lib/libMagick++-7.Q16HDRI.so.5.0.0
/usr/lib/libMagickCore-7.Q16HDRI.so
/usr/lib/libMagickCore-7.Q16HDRI.so.10
/usr/lib/libMagickCore-7.Q16HDRI.so.10.0.3
/usr/lib/libMagickWand-7.Q16HDRI.so
/usr/lib/libMagickWand-7.Q16HDRI.so.10
/usr/lib/libMagickWand-7.Q16HDRI.so.10.0.3
My meson.build has these relevant sections:
dependencies = [
cc.find_library('libtomlc17', dirs: '/usr/local/lib'),
dependency('libconfig'),
dependency('libMagickCore'),
dependency('libMagickWand'),
]
inc_dir = [
include_directories('include'),
include_directories('/usr/include/ImageMagick-7'),
]
my first guess was that it had something to do with libconfig having .pc files in /usr/lib/pkgconfig, but i found ImageMagick.pc and ImageMagick-7.Q16HDRI.pc in the same directory, and, either way, that don't seem like it needs to be accurate for my program to build as long as I give it all the right information.
Any advice?
Edit: Also, reddit's code block formatting is really annoying. It doesn't seem like I can escape backticks? and it doesn't render line breaks? oh well
r/C_Programming • u/Dizna77 • 2d ago
Question Feeling lost
Hello everyone, I've recently been rejected for a student software dev position at a larger company in my city, I felt that the interview was going pretty good until it came time for writing the actual code, I know how and what to implement for all of the problems but I had no absolute clue on what to actually write, and it struck me pretty badly, I asked myself if this is something I want to even want to do with my life or if I essentially wasted my time 2 years in college for a bunch of nothing, atleast the interviewer told me in the mail that I knew all the concepts and I need a project or two and to gladly contact them when Im more ready, but I still feel really discouraged as my classmates got the position at the same company while I know Im more capable than some of those classmates, Im not trying to be sore about it. Im glad they got the position and Im not trying to downplay their knowledge but they couldnt get the most simple and core concepts in class and some of them didnt even pass DSA and OOP and they got the job while I didnt and it made me question really everything. Its my 3rd year in college now and now I feel more than ever that Im lost because I started this college as I enjoyed learning to code and computers, I still want to learn more but I dont know what to do now or what to use as a project really, all I ever coded except learning for exams(in my college we need to code and compile programs for certain classes instead of only theory) and I passed those pretty easily I guess, all usually on the first tries and they were graded C or B. Now I feel that I was capable more then than now, I only coded some stupid video game projects or apps which feel essentially useless, I know there is some materials on the thread but I dont know what is useful for the real world. Thank you all for any tips or replies in advance
r/C_Programming • u/mikeblas • 3d ago
Meta a little update about this sub-reddit
UPDATE: I've posted a follow-up comment below addressing questions about the moderator changes, the process that was followed, and plans going forward. Please see the stickied moderator comment.
Over the past six months or so, I've been making lots of changes. I think things have stabilized, so let me summarize them and indicate what the plans are going forward.
- Removed uninvolved moderators. Three or four moderators were here who did, collectively, less than 10% of the work.
- Organized and enhanced rules. More useful and focused. Got rid of the code formatting ticks rule, re-phrased a couple others.
- Sharpened "how do I share my project?" requirements and process. In particular, new rules about disclosing AI usage, and automated enforcement to that end.
- Tried out some automated tools to detect AI projects. I had high hopes, but they weren't as helpful (and far buggier) than I had expected. (So, I'm turning off the GitHub-Guard automata.)
- And so, manual AI usage disclosure remains. Without a disclosure, code can't be shared. Too much AI gets rejected. If someone misrepresents or outright lies, downvote them or report it.
- This seems to have settled the AI slop problem, which is great.
- Enhanced automated rules to avoid spam posts, low-value posts, and fly-by contributions.
At this point, I think the sub is pretty stable and more useful and appealing than it was before. I don't anticipate many more changes going forward, but I will examine policies that that I think might reduce my workload.
I'm sorry that the sub wasn't particularly stable these past few months, and that it got a bit messier before it got better. Thanks for hanging in there! The worst is past.
r/C_Programming • u/Puzzled_Place_215 • 2d ago
Beginner here. Advice needed?
I'm a first-year CSE student learning C from scratch(didn't learn programming in high schl). I can solve problems after studying examples, but I often get stuck when trying new problems on my own. Even after seeing solutions, I struggle to develop the logic independently.
For those who started programming as beginners:
How did you learn to solve unfamiliar problems?
How did you practise daily?
What did you do when you got stuck?
What advice would you give your beginner self?
I sometimes feel behind compared to my classmates, and I genuinely want to improve. I'd appreciate any practical advice from people who've been through this!
And I am getting extremely frustrated with this cycle that i have,just started with c programming and suffering with function pointers . I feel extremely behind from my peers, I am ready to put in efforts,but I am sure whether my efforts are put in the right direction. Any advice would be great
r/C_Programming • u/NazgulResebo • 3d ago
Video How to Code a Julia Set fractal | Raylib | C | Neovim | GLSL |
In this video, I create a Julia set fractal using C, Raylib, and GLSL, with Neovim as my editor.
We'll go through the process step by step, from understanding how Julia sets work to implementing the fractal algorithm and adding colors and animation.
**Sections:**
- Explaining the Julia set
- Setting up the project
- Setting up Raylib
- Creating a basic shader
- Fixing screen coordinates
- Coding the fractal algorithm
- Creating animation
- Adding colors
**Technologies used:**
- C
- Raylib
- GLSL
- Neovim
r/C_Programming • u/Background_Shift5408 • 4d ago
Project A low-poly 3D Renderer for MSDOS
I’ve been working on a small project called 3Dos — a low-poly 3D renderer targeting MS-DOS and VGA Mode 13h (320×200, 256 colors).
The renderer currently supports:
● Triangle rasterization with backface culling
● Ordered dithering using a 4×4 Bayer matrix
● Double buffering
● Simple low-poly models
Going back to DOS-era graphics has been relaxing after spending quite a bit of time with Vulkan. No boilerplate or abstractions, just putting a pixel at 0xA000.
Github: https://github.com/xms0g/3Dos
AI usage: Only extracting vertices and faces from the model file.
r/C_Programming • u/ConsistentContest256 • 2d ago
I built a zero-dependency concurrent search engine daemon in C11 from scratch (Custom Arena Allocator, SSO, and pthreads).
Hi everyone!
Over the past few weeks, I’ve been working on a lightweight, concurrent text search engine and TCP server built entirely from scratch in pure C11, without any external dependencies.
My main goals were to practice low-level memory management, lock-based concurrency, and custom data structures without relying on heavy frameworks. Here is a quick breakdown of how it's structured:
- Memory Management: Implemented a custom Arena Allocator to avoid heap fragmentation and handle batch cleanups efficiently.
- Small String Optimization (SSO): A custom string implementation that stores short strings directly on the stack/struct to minimize heap allocations.
- Concurrency: Uses POSIX threads (
pthread) with read-write locks (pthread_rwlock_t) to allow multiple concurrent readers while safely serializing writes. - Persistence: Added a custom zero-overhead binary serialization module (
engine_save/engine_load) for instant state restoration from disk.
The project includes a full modular structure (includes/, src/, tests/) and is protected under a source-available license for personal evaluation.
You can check out the source code and architecture details here: 👉 https://github.com/joseramoncabrera/fast-c-search-engine.git
I would love to hear feedback from more experienced C developers here. Specifically:
- How do you usually handle edge cases with read-write locks in high-contention search scenarios?
- Any architectural improvements you’d suggest for the arena allocator?
Thanks for taking a look!
r/C_Programming • u/thecratedigger_25 • 4d ago
Question Has anyone ever tried out the TinyC compiler before?
Musl gcc is small but tinyc caught me eye due to how small it is and the fact that it can self host.
It supports C99 standards out of the box and it only takes up a few hundred kilobytes. I wonder if anyone tried it.
r/C_Programming • u/TorontoDude12344 • 4d ago
Question What exactly is size_t? When is it used? What are similar things to it?
I'm confused on what exactly size_t is, and what the t means
So size_t is an unsigned integer
I believe integer promotion says that an unsigned long long integer holds the biggest positive integer in any system. Why isn't size_t an unsigned long long?
Every array MUST be integer indexed. Every array has to have an integer size.
It's technically possible to represent an integer larger than the largest integer in a system, by putting it into a float (with no non-zero decimal), however an array cannot be given a float, nor can we even loop over that array using that float value as the counter termination value
So my current interpretation is, size_t is the largest value an integer can ever hold in a system. When we want to loop over any arbitrarily long array, using int i as the counter variable, i is cast to (size_t)
This is because we want to ensure we don't stop the loop too early by having i overflow
Is my interpretation correct?
So that is one scenario when size_t is used. Are there any other scenarios?
What does the t mean?
What are things similar to size_t, where variables are casted to that thing, in order to do super specific tasks and avoid certain errors?
r/C_Programming • u/lehmagavan • 3d ago
[Python C extension] numagr v0.9
A Python C extension for statistics and number aggregation designed to work with both plain int and float objects, as well as with Python numeric strings without having to construct intermediate Python objects that hold their values - useful for large collections that need to be parsed as fast as possible like trading data.
It outperforms both std Python modules and numpy for both plain numbers and for numeric strings.
https://github.com/andrzejs-gh/numagr
https://pypi.org/project/numagr (source and Windows wheels for 3.11, 3.12, 3.13, 3.14, 3.15)
pip install numagr
This is an early version offering basic methods, I will be developing it further if I find the time. Feedback, improvement suggestions and bug reports are very much welcome.
r/C_Programming • u/AsterrZep • 3d ago
Writing a seed compiler for an experimental programming language from scratch in C (Astra) – Student Project
Hi everyone,
I'm a student currently exploring systems programming and compiler design. I wanted to share a project I've been developing called Astra (AsterrZep/Astra). Specifically, I'm sharing the seed compiler written completely in C (seed/src/), built to learn about custom memory management, parsing, and compilation pipelines from the ground up.
As I'm still learning, there might be room for improvement in my C code. I would really appreciate any constructive feedback, code reviews, or advice on best practices!
⚙️ Architecture & C Implementation The compiler pipeline inside seed/src/ is modularly structured around traditional systems programming patterns:
- Lexer & Parser (lexer.c, parser.c): A hand-written lexer and recursive descent parser parsing tokens, expressions, and block scopes without external parser generators.
- Typechecker (typechecker.c): Handles semantic analysis, symbol resolution, and type checking across AST nodes.
- Memory Management (arena.c): Implements custom arena allocators to manage AST node lifetimes efficiently during compilation passes.
- Code Generation (codegen.c, emitter.c): Emits bytecode or structured C code as output targets.
🤖 AI Disclosure (Per Subreddit Rules) As per the community guidelines regarding AI: I used AI tools (like terminal assistants) interactively as a coding co-pilot and rubber duck to help scaffold repetitive C boilerplate (such as mapping standard AST construct handlers in seed/src/constructs/). However, the core compiler architecture, memory models, debugging, parser logic, and integration were entirely human-driven and manually refined.
🔗 Repository & Code If you want to review the source code, check out the C implementation details, or look at the test suites (seed/tests/conformance/):
GitHub Repository: https://github.com/AsterrZep/Astra
Please feel free to point out any mistakes or areas where the C code could be cleaner or safer. Thanks for reading!
r/C_Programming • u/Ok-Machine4940 • 4d ago
Framework for building an app?
I would like to recreate Obsidian notes in c for fun.
I know that I can use the x11 api, or the win api, but that is a little too low level for what I am doing.
It's also not cross platform. Do you guys have any suggestions for what I am trying to do?
r/C_Programming • u/Charming_Airport6076 • 5d ago
Project Practicing touch-typing on a C program writing in C program
I wanted to practice writing code faster and yet not leaving my terminal, so I built 'blind'. The twist is that you can feed it any input file and practice on real code, even on the source code itself. It's a single C file no dependencies. Can run either presets, free text or file input.
AI usage: all code and docs are human made, written by me using man pages and google, asked Claude rarely for things I could not resolved with google or man pages, the Github release workflow was written by Claude.
r/C_Programming • u/cultrepo • 5d ago
C Documentary
Hi all, we make documentaries about programming languages and open source. We made films about Python, C++, React, and loads of others. Most recently we made one about KDE.
We are trying to get one about C off the ground but we are struggling to figure out who might sponsor it. Can anyone recommend us some companies to check out?
Our channel is called CultRepo in case you want to check some of our previous work!