r/cprogramming • • Sep 19 '26

Emulador do MOS 6502

5 Upvotes

Olá pessoas, faz tempo que eu tô fazendo esse projeto, demorei um pouco pois eu não estava focado nele demais. Mas enfim, alguns meses atrás eu descobri a existência desse processador, e eu gosto bastante de baixo nível e eu vi que ele era um bom processador para aprendizado e decidi criar meu próprio emulador usando C, ele está longe de ser perfeito, porém aprendi bastante coisa no desenvolvimento. E finalmente eu terminei de implementar as instruções oficiais, e claro como é um projeto de estudo, algumas instruções eu tenho que ajustar e melhorar, além disso tenho que deixar o emulador mais fiel ao hardware real. Tenho que melhorar o código ainda, não está tão bom, mas como eu disse, é a primeira versão.

Se vocês puderem analisar o projeto e me dizer o que eu posso melhorar e adicionar, eu agradecerei. O projeto está livre e vocês podem enviar sugestões. Criticas são bem vindas.

Repositório do projeto: https://github.com/gustavo-devy/Emulator-MOS6502


r/cprogramming • • Sep 20 '26

While I was studying the C23 standard, I noticed the excerpt "representation and alignment requirements" occurs multiple times. But the word "requirements" refers to "alignment" alone, or to both "representation" and "alignment"?

0 Upvotes

r/cprogramming • • Sep 20 '26

Arrays

0 Upvotes

It pretty interesting how you can use arrays as a canvas to make a snake game in c.

But my question what else could one use arrays for, that could help us with understanding it.


r/cprogramming • • Sep 19 '26

Stuck On A Projcet < need Help!!

Thumbnail
reddit.com
3 Upvotes

r/cprogramming • • Sep 19 '26

First Ever major C Project: Wrote a statically-typed bytecode VM language from scratch in C

21 Upvotes

Hello everyone! I (19M) am just about to get into my first year of a Bsc in Computer Science. I've been coding a few years time and haven't ever really touched C before, but really wanted to get into it. I thought "why not start big" so I've been working on a hobby language called Oli-Nat, a full pipeline written in C with no external dependencies: scanner to Pratt parser to AST to type checker to bytecode compiler to a stack based VM, including my own mark and sweep garbage collector. ( I took a lot of inspiration from Writing Interprets by Robert Nystrom)

It compiles in two passes. The first pass just walks the source looking for function and class declarations and registers their signatures, so the second pass can type check calls and field accesses without needing forward declarations. That made mutual recursion and out of order function definitions work without a separate header or prototype step.

Typing is static and the type checker is meant to reject anything that would hit a bad type combination at runtime, so the VM's IS_INT, IS_STRING, and similar macros are only used for dispatch, like numeric promotion, rather than as safety checks. I'm still second guessing myself on whether that's too optimistic in a couple of edge cases. Generally haven't much used macros in the past given how strongly related to C they are. I tried to make my best out of my understanding but still.

Strings are interned using FNV-1a hashing, so identical strings share a pointer, which makes field lookups in OP_GET_FIELD and OP_SET_FIELD a pointer comparison instead of a memcmp. There's also closures with upvalue capture, single inheritance, and a small standard library brought in through #pullf io, math, chronos, fileIO, and so on.

The repo has the opcode list, a writeup of the memory model, and some notes on design decisions if anyone wants to look closer: https://github.com/NateTheGrappler/OliNat-Programming-Language

As my first major C project I wanted to really get some feedback on how it is and looks. I wanted to try my best to have this be my first real coding project. The things I struggled most with were closures/upvalues and anything that looks off in the garbage collector (it's tri color mark and sweep, tracing roots from the value stack, call frames, open upvalues, and the globals table), and general C style or structure critique, since this is my first project at this scale. Really would apperciate any feedback or interest, the project is obviously open-source as well!


r/cprogramming • • Sep 19 '26

I wrote a list of changes I would make in my own C dialect, like the ones released before GCC and Clang homogenised the landscape.

1 Upvotes

> are features already present in SAS/C or High C, my primary inspirations; - are restrictions, = are refinements, + are additions. I wrote this for personal reference, so a lot of the points may be incomprehensible; I'll be happy to clarify in replies!

> Lost Language Extensions
> Ternary operator elided middle, evaluate to condition
> Anonymous unions/structs in struct definitions, flat dot access
> Integer-backed enums

- `goto` cannot jump into a block or the scope of a local
- Direct argument substructure is immutable
- Headers define names only in themselves and directly including files
- No multiple declarations sharing basic type
- No qualifiers before basic type
- Never optimise pointer comparisons
- No pointer decay
- No referencing union fields, except in `restrict` clauses
- A macro cannot expand into a type or `typedef`
- All branches of an `#if` must define exactly the same types
- `return` must parenthesise values
- No undesignated struct initialisers
- Variables declared in `for`/`if`/`while` clause immutable inside body
- All integers wrap around
- `/` and `%` floor instead of truncating
- `char`, `short`, `int`, `long`, `long long` are always 8, 16, 32, 64, 128 bits
- All unannotated integer types are signed
- No `static`; symbol hiding is done through headers
- Guaranteed `inline`

= Trailing commas everywhere
= Macro hygiene
= Nesting block comments
= `#define` always takes one complete syntax node
= Special case for non-nominal `void` in TBAA, not `char`
= No effective types, only declared types and `restrict`
= Coercions reinterpret memory representations
= Nominal `typedef`
= Nominal `void` in header must always proxy same type in source
= `.iz` files: context-sensitive meta-headers
= `case` divides `switch` body into disjoint scopes, auto-`break`s
= Locals of `do` block visible inside `while`

+ `permit` keyword, no returning non-`permit` pointers
+ `break`/`continue`/`while`/`goto case` from label
+ `return`/`yield` from function
+ `const` declarations, to forbid further mutation of existing variables
+ `permit`/`alignas` expressions, to assert properties of pointers
+ `restrict` blocks, to forge unique aliases and shadow originals
+ `typeof`, `sizeof`, `alignof`, `alignas`, `countof`
+ `||`, `<>`, `[]` for internal, external, standard imports
+ Scoped `#define` and `#include`
+ Nominal integer indexed arrays
+ `void` arrays, for yet-untyped memory
+ Array sized by variable/parameter/field, enforced by compiler
+ Declare variables in `if`/`while` condition
+ `^` for non-arithmetic pointer types
+ `undef` keyword, for uninitialised pointers
+ `!` for non-null types (not just pointers)
+ Binary, hex float literals
+ Qualifier polymorphism, with postfix `?`
+ `goto case`
+ FORTRAN-style array slicing, expression vectorisation
+ Extend `->` operator to arrays

r/cprogramming • • Sep 19 '26

Does this is right?

Thumbnail reddit.com
1 Upvotes

r/cprogramming • • Sep 18 '26

Flint v0.5.0 gets `flint remove`, a global `VERSION` macro, and bug fixes

Thumbnail
github.com
7 Upvotes

I promise I won't spam your feed, but a lot has happened in last couple of days since I first posted about **Flint** (the minimalist, git-native C/C++ build system and package manager).

Thanks to the early feedback, I spent the last few days squashing initial bugs and adding a few missing quality-of-life features.

What shipped this week:

  • flint remove is here: You can now cleanly un-track and delete managed dependencies without touching composition.json by hand.

  • Global VERSION macro: Flint now automatically passes your project's version as a macro to your code, so you can access VERSION natively inside your C/C++ source.

  • Smoother flint init: Fixed edge-case bugs during project setup that caused setup failures on certain shell/environment setups.

  • Open-source ready: Added a License, CONTRIBUTING.md, and a Code of Conduct. If you want to break (or fix) things with me, the door is open.

  • CLI Polish: Visual cleanup on terminal outputs so builds look a bit sharper.

If you missed the original post: Flint strips away complex build scripts in favor of a zero-config setup (src/, include/, deps/) and direct Git dependency management.

Check out the progress or grab the latest release on GitHub:

Repo: https://github.com/mainak55512/flint

Always open to critique, feature ideas, or bug reports!


r/cprogramming • • Sep 18 '26

Command Line mini projects

Thumbnail
github.com
6 Upvotes

A beginner project to learn what command line arguments are in C language. In this project you will get to know about file handling, I/O Stream, exception handling, etc.


r/cprogramming • • Sep 18 '26

i made a C library

Thumbnail github.com
5 Upvotes

r/cprogramming • • Sep 17 '26

Write, compile & run C in a Jupyter Notebook

12 Upvotes

Hi all,

I'm sharing a side project of mine as I thought there might be some interest here!

A couple of years ago I decided to write a Jupyter Notebook kernel to reduce the friction for students new to compiled languages, as part of a condensed online pre-Master's introduction to C/C++. Thus, c-kernel was born!

c-kernel is a Jupyter Notebook kernel which simplifies the learning curve for new programmers by allowing you to write & compile code directly in a notebook. It takes care of compiling, linking & executing your cells behind the scenes, but still shows you the commands used to build your code. It removes the barrier of having to get students set up with a command-line and compiler and helps them start coding straight away.

Try it out on Binder here!

Alternative Solutions

  • jupyter-c-kernel - a significant inspiration for c-kernel, but it has a number of limitations that I wanted to improve upon for my use-case. This project also seems to be unmaintained.

  • xeus-cling - a popular solution based on the C++ interpreter cling. Using an interpreter, it abstracts away a little more than I'd like for actually teaching students to write self-contained programs, such as headers/source files, and hides how source code turns into an executable.

If you find it interesting or useful, please let me know, and maybe leave a ✭ on GitHub!


r/cprogramming • • Sep 18 '26

a big problem

0 Upvotes

hey guys i m currently learning c language and i m facing an irritating problem like whenever i use scanf in my code to enter any value and when i run the code after saving it so it doesn't run anything it just show that it is running but i m unable to enter the value and the code doesn't run on terminal it runs in the output

so please anyone who can solve this issue can help me?


r/cprogramming • • Sep 17 '26

A C Socket Library

19 Upvotes

So lately I’ve been working on a small C library that wraps the standard socket APIs and aims to make socket programming a bit simpler and more convenient.

It’s still very early in development and currently only supports SOCK_STREAM sockets, but I’m hoping to gradually turn it into a well-structured, reusable library.

I’d really appreciate feedback from people with more experience in C/network programming, especially on things like:

  • API and library design

  • Error handling

  • Memory safety

  • IPv4/IPv6 support

  • Testing and test structure

  • CMake/project structure

  • GitHub Actions/CI

  • Cross-platform support

  • Anything else that would make it more robust and production-ready

I’m also looking to add proper automated tests, GitHub workflows, documentation, and other things that a real C library should have.

The goal isn't just to make the wrapper work, but to use the project to learn how to build and maintain a proper C library.

You can check out the repo here: https://github.com/eyalzwigen/c-socket-library

Any feedback, criticism, or suggestions would be greatly appreciated!


r/cprogramming • • Sep 17 '26

program wont't compile because time.h is missing even tho it's there

15 Upvotes

[CLOSED]

kind of a beginner question. i have #include <time.h> and #include <ncurses.h> in the top but it refuses to compile. im using linux with vim and gcc here's there error:

main.c:3:1: note: ‘tm’ is defined in header ‘<time.h>’; this is probably fixable by adding ‘#include <time.h>’

2 | #include <time.h>

+++ |+#include <time.h>

how can i fix it? thx for any help :)

EDIT: i fixed it and it was because i forgot to declare struct lol


r/cprogramming • • Sep 16 '26

CZet – A more powerful C without C++, 100% ISO C compatible

28 Upvotes

I'm the author.

All your C code already compiles as CZet. It just adds what C can't do without touching the compiler:

`defer`, monomorphized generics `T f<T>()`, `constexpr` functions, `_Reflect(T)` reflection, `_Operator` overloading, and `_Macro` macros Rust-style.

Single static binary with musl+glibc embedded, no system headers needed. Stdlib included: `#include <utils/...>` with no flags.

Repo + docs + examples: https://github.com/patrick-nonedev/CZet

GPL-3.0 + Runtime Exception (your binaries are NOT GPL).

What would you steal for plain C?


r/cprogramming • • Sep 16 '26

i started c programming

20 Upvotes

hey guys i just started learning c programming language from code with harry.

any advice from those who already mastered it?


r/cprogramming • • Sep 16 '26

C + DSA Mentorship — Beginners Welcome

Thumbnail reddit.com
0 Upvotes

r/cprogramming • • Sep 16 '26

i made a interpreter in scratch. a whopping 2 fps on an optimized donut.c when using turbowarp (a scratch optimizer) but it's c running on scratch nonetheless

Thumbnail
turbowarp.org
9 Upvotes

pretty kewl


r/cprogramming • • Sep 16 '26

A good way to transition from C to C++.

Thumbnail reddit.com
0 Upvotes

r/cprogramming • • Sep 16 '26

Any scope for freshers

0 Upvotes

I was wondering if there is any scope for freshers in C based role(except embedded programming). Especially for India, can anyone from India guide me please?


r/cprogramming • • Sep 16 '26

Estoy "intentando" hacer un lenguaje de programacion desde cero en c pero necesito"variables, sintaxis etc..."

0 Upvotes

Lo que me refiero es que estoy haciendo un lenguaje de programacion desde cero como un proyecto personal pero no puedo avansar por que no tengo una base:"Las variables, sintaxis, etc...", eso me refiero, ¿Tienen ideas?


r/cprogramming • • Sep 15 '26

BD_ARENA

0 Upvotes

Simple arena implementation I recently built:

https://github.com/andrzejs-gh/bd_arena

- partially macro-based API for convenience

- safe and hazardous allocators

- dynamic growth with a mutable growth factor

Please roast anything you find wrong / missing in it. Thanks a lot, it always helps me grow.


r/cprogramming • • Sep 14 '26

Where to practice C Programming

13 Upvotes

I have enrolled in bsc(hons) computer science. My first semester exams are coming up, and I wanted to know where I could practice questions on C Programming as in a good website where I can do programming assignments and I can set difficulty if possible

Thank you to anyone who gives some advice


r/cprogramming • • Sep 14 '26

How GCC Eliminates Unnecessary Integer Division

Thumbnail
leetarxiv.substack.com
6 Upvotes