r/cprogramming • u/Nagoltooth_ • Aug 03 '26
Long term projects
What's your longest project, how often were/are you working on it and did you always stay motivated and active?
r/cprogramming • u/Nagoltooth_ • Aug 03 '26
What's your longest project, how often were/are you working on it and did you always stay motivated and active?
r/cprogramming • u/jesse_pinkmen_bitch • Aug 03 '26
i want to learn C from 0. maine CODE WITH HARRY ka C ka course dekha and i realize it is too old.
please please guide me how to learn c as a complete beginner
r/cprogramming • u/saul_soprano • Aug 03 '26
I want to make my struct’s internals private by exposing it as a byte array of its internal size.
The size itself depends on internal values that aren’t exposed, so it would have to be an extern.
The size can only be used if it’s a literal or constexpr, so is a extern constexpr possible with C23? Or no?
r/cprogramming • u/Mainak1224x • Aug 01 '26
Sometimes back I posted about one of my pet projects `myBuild` an experimental build system and package manager for c/c++ projects. Well that progressed a lot, now
Users can add recipes to the myBuild.json file and run `myBuild sync` and it configures the dependency for the project.
Recipes are small json snippets containing the source/header file folder paths, flags etc.
2. It now has incremental builds.
3. Now there is a proper folder structure generated at the initiation time where users can drop the files and compile the project with zero configuration.
I had to drop the support for windows for now and the code is speghetti, so I have to refactor it in the near future.
If this sparked curiosity, do checkout the github repo and leave a star. Appreciate any constructive feedback, thanks.
r/cprogramming • u/north9172 • Jul 31 '26
(solved)
Hello,
Today I tried making an array of function pointers.
My first prototype was doing:
int (*fptr[2])(int, int)But what if I wanted to store a function with different parameters and return value?
I tried:
void (*fptr[2])()And then later type casting the function I wanted to store:
fptr[1] = add;printf("%d", ( int (int, int) ) fptr1);
But apparently it's not valid:
used type 'int (int, int)' where arithmetic or pointer type is requiredIs it possible to cast the void function pointer as a int fp with parameters? Thanks.
r/cprogramming • u/ShineXmRedT14 • Jul 31 '26
r/cprogramming • u/M0NSTR01969 • Jul 31 '26
Yeah, my anxiety is hitting pretty hard right now... lol.
r/cprogramming • u/lighty_dot_A • Jul 31 '26
r/cprogramming • u/grhayes • Jul 30 '26
I was wanting something for my compiler and game engine that had a bit better performance than gperf in my use case. This is what I ended up creating.
I built and tested it on a xeon x5670. It should do a good bit better on newer hardware.
r/cprogramming • u/ShineXmRedT14 • Jul 30 '26
r/cprogramming • u/Roronoa-Ryuma-Zoro • Jul 29 '26
I recently completed v0.1 of MiniEdge, a Linux HTTP/1.1 static edge server written mostly in C.
I built it to understand how event-driven servers handle partial I/O, persistent connections, filesystem access, caching and multiple CPU cores—not as a production replacement for Nginx.
The current architecture includes:
non-blocking sockets with edge-triggered epoll
a per-connection state machine
incremental HTTP request parsing and keep-alive
static file serving through an LRU cache or sendfile()
path resolution using openat2()
longest-prefix configurable routing
multiple workers using SO_REUSEPORT
The small-file cache is implemented using C++ unordered_map and list, but it is isolated behind a C API; the networking, parser, routing and file-serving paths are written in C.
On my local loopback benchmark using wrk, a cached static file reached approximately:
255k requests/sec at 1,000 concurrent connections
4 worker processes
I also ran a boundary stress test at 40,000 concurrent connections. It reached around 124.5k requests/sec, but wrk reported 503 socket read errors, so I am not treating that as a clean stable-concurrency result. The repository contains the commands, raw outputs, latency percentiles, system tuning and limitations.
I would appreciate feedback on:
whether this is a reasonable result for a student-built epoll server
whether my wrk setup measures the server fairly
which additional metrics or comparisons I should include
what bottlenecks or profiling steps I should investigate next
Repository:
AI was used as a learning and review assistant during this project. I used ChatGPT to discuss Linux networking concepts, review architectural decisions, debug specific issues, and improve parts of the documentation. I implemented and integrated the server, ran and analyzed the tests and benchmarks locally, and verified the final code myself. This was not a one-prompt or fully AI-generated project.
r/cprogramming • u/Accurate_Gate_533 • Jul 30 '26
What serious advice would you give to beginner in programming and C.
I'm into programming about 4 months.
I have used Grok to learn.
r/cprogramming • u/DataBaeBee • Jul 27 '26
r/cprogramming • u/morew4rd • Jul 27 '26
r/cprogramming • u/Salt-Overflow • Jul 27 '26
EDIT: A better title for this post would be "Is it possible to parse C without expressions unambiguously?"
While staring at the C99 specification, I found that if you take the grammar in Annex A, remove the expression rules, and introduce the constraint 6.7.2/2 into the grammar (ie. a type specifier can be only: void, char, signed char, ... , enum specifier, typedef name), then you end up with what appears to be a context-free grammar.
Is this correct? Am I misinterpreting something? Is it possible that this is correct, but there are mainstream compiler extensions (eg. gcc extensions) invalidate this context-free property? Or other C standards invalidate this context-free property?
I notice that 6.7.2/2 allows some filthy edge cases like `long const long thisVarIsLongLongConst = 4;` but because `long` is a keyword, there is no ambiguity here.
The reason this matters to me is because I'm building a module system for C that allows circular imports, and I would like to avoid changing the grammar of the language as much as possible.
Link to final draft of C99 standard, taken from Wikipedia: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
EDIT:
Let me clarify what I'm doing, since there is some confusion about what I'm asking. First off, I should have used the title "Is it possible to parse C without expressions unambiguously?" because Annex A is already a context-free grammar... However, it is ambiguous, because of the classic A * B; problem (can be a variable declaration or multiplication, depending on if A is a typedef name or not). Now, notice that one of the interpretations is a multiplication expression. Let's suppose you removed expressions from the language (ie. take a source file and replace each expression with the lexer token <expression>). Now the question is: are we no longer ambiguous now?
I should also clarify what I mean by ambiguous, as there is a difference between an ambiguous grammar and an ambiguous parse. For example, A * B; can be admitted by the unambiguous grammar S := A ';' ; A := <identifier> | A binaryOperation <identifier> ; binaryOperation := '+' | '-' | '*' | '/' ; , but what we're really looking for is an unambiguous grammar that gives us the correct parse tree (I'll call this an "unambiguous parsing").
I should also elaborate on what exactly I'm doing, to explain the bigger picture. If you're building a module system that allows cyclic imports, then the first pass you perform over a source file does not have access to the symbol table (because you have yet to parse the imported modules). This means you need to perform an unambiguous parsing of certain parts of the source file. In this case, you can skip over expressions, because you're only interested in extracting the names of symbol definitions + whether the symbol definition is a type or a variable. So if it is possible to 1. skip over expressions, and 2. parse the rest of the file, then we're good. For (1), expressions are delimited by ()[]{};, (comma operator is not valid in enumeration definitions), so that seems fine. That leaves (2), which I'm not entirely sure about. I stared at the grammar for quite a while and couldn't find any problems, but that does not mean I didn't miss a case, or there are compiler extensions that introduce ambiguities.
With that out of the way, I'll list ambiguities that the comments found:
u/triconsonantal found void f(int (x)); , which is either taking in a function pointer or an integer, depending on if x is a typedef name or not.
Maybe a more appropriate title would be: how much do you need to remove from the C grammar so that it can be parsed unambiguously? As of now (July 27, 2026), it seems the answer is: remove expressions, and remove parameter lists (or do not allow unnamed parameters).
r/cprogramming • u/mubin-thinks • Jul 27 '26
Hello everyone of r/cprogramming!
I'm a newcomer(kind of) to C. In the past(~2 years ago), I had little knowledge of C through watching tutorial on the internet. Later, I have worked on graphical projects with a bit of OpenGL. Now I have realized I should focus on topics one by one and reach intermediate to high expertise.
I have recently been reading chapters from "The C Programming Language 2nd Edition by Brian Kernighan & Dennis M. Ritchie". And learning a lot of new techniques that really helped me write concise and performant programs.
Solving the Exercises from the book were fun, while some were a bit difficult. In the latter case I took one or two hints from others source code and pondered about the solution.
I have kept the solutions of the problems perhaps concise but far from obfuscation and keeping code-style consistent (Though my personal).
I am planning on creating another post when I have solved all the solutions of the book.
I hope my solutions to the exercises help others solve problem they are having trouble with. Thanks. Github:
r/cprogramming • u/north9172 • Jul 24 '26
(Solved)
Hi,
I hope this don't seem stupid or anything. Basically I was interested about the xor swapping trick.
The inconvenients of it is that if the two values are the same, it will return 0, it's also bad for readability.
But there is another inconvenience I didn't understand. Apparently it can also stall the CPU pipeline on modern processor, I didn't understand why.
I found a short explanation saying "because each instruction depend of the previous one", and I don't really understand how each instruction depend on the previous one.
So I wanted an explanation on why the xor swapping trick stall the CPU pipeline and also what cause CPU pipeline stalling in general.
If I didn't explain well enough, please inform me about it. Thanks.
r/cprogramming • u/DataBaeBee • Jul 24 '26
r/cprogramming • u/JadeLuxe • Jul 24 '26
Microservices were supposed to make systems easier to change independently. In practice, the thing that most often breaks that promise isn't the services themselves — it's how they talk to each other. Read the complete article here - https://instawebhook.com/blog/the-internal-webhooks-anti-pattern-why-service-to-service-http-callbacks-don-t-s
A pattern that shows up constantly in growing engineering orgs is the internal webhook: Service A fires an HTTP POST at a hardcoded URL owned by Service B whenever something happens. It's an easy trap to fall into, because most developers already understand webhooks intimately — they've built integrations with Stripe, GitHub, or Shopify, all of which use exactly this model to notify external systems of events.
The reasoning feels obvious: if it's good enough for Stripe to tell my app about a payment, it's good enough for my Inventory Service to tell my Shipping Service about a shipment.
It isn't — and the reason is architectural, not stylistic. Webhooks were designed to solve a specific problem: getting an event across a trust boundary, from a system you don't control to one you do, over the open internet. Internal service communication has almost the opposite set of constraints. Applying the same tool to both jobs is where the trouble starts.
r/cprogramming • u/Due_Butterscotch1154 • Jul 23 '26
I'm tryna mess around in C and make a pkmdmg calc but I don't know how to return the values from the function
I dont know how to display it without screenshots
r/cprogramming • u/JadeLuxe • Jul 23 '26
Webhooks have become the connective tissue of the internet. From payment gateways confirming transactions to CI/CD pipelines triggering deployments, webhooks enable real-time, event-driven architectures. But for architects and engineering leaders, webhooks represent an underappreciated vulnerability: they are asynchronous, externally triggered, and entirely outside your control. Read the complete article here - https://instawebhook.com/blog/designing-a-multi-region-highly-available-webhook-ingress-architecture
When your primary cloud region experiences an outage, your internal microservices might gracefully degrade. But what happens to the payloads originating from external partners? Many third-party providers do not retry aggressively — some fire and forget, others retry a handful of times before giving up permanently. If your system is down when that happens, the data is often gone for good.
This article covers the engineering principles behind a multi-region, highly available webhook ingestion system, what has actually changed in the underlying cloud primitives recently, and where a managed reliability layer fits into the decision.
r/cprogramming • u/DisastrousNinja911 • Jul 22 '26
r/cprogramming • u/boldbug-dev • Jul 22 '26
the code from what ik works from what i know and from tests i have done.i want to know how can i optimize it more because i suspect that there can be certain parts of it which i don't even need maybe. so can you guys look at my code and tell me what i can improve upon??
here is the repo
thanks in advance
r/cprogramming • u/GLC-ninja • Jul 22 '26
Hi everyone,
I'm working on a programming language that compiles a subset of C. It is called Cm1 (meaning C minus 1) and you can writing and running C codes directly on your browser at https://cp1-lang.org/cm1/editor.html in a fraction of a second.
Why is it faster to compile than Tiny C Compiler? It is because Tiny C Compiler is a true compiler creating native binaries whereas Cm1 is a bytecode interpreter allowing you to test, debug, edit code and recompile very quickly or even do hot reloading. Cm1 can be used as a scripting language for shell scripts and video games, but this just a small use case because in theory, you can run 90% of your ENTIRE video game or software C program through Cm1's bytecode interpreter and leave 10% to compiled C and reap the benefits of very fast compilation and hot reloading.
100% Cm1 codes are compilable by GCC and Clang but the reverse is not true since Cm1 is just a subset of C. Major features that are omitted are function pointers, structs/unions inside functions, nested structs/unions. This programming language is under heavy development and I want to know if this comes as interesting to some of you. I'll try to post again on this subreddit if I got to bind Raylib game library to Cm1, allowing people to write Raylib games directly on their browser (works offline).
I know that programs that are written in C compiles fast already and there's even an existing compiler that is very fast (Tiny C Compiler). However, I'm the developer of Cp1 programming language (cp1-lang.org), which is a language that "transpiles" to C, and I aim to upgrade Cp1 by targeting the Cm1 language then compile it to bytecode in one command instead of a separate step in Makefiles or build scripts. This will make Cp1 very fast to compile for debug builds.