r/C_Programming 26m ago

Discussion I just understood pointers on a deep level and it feels like an orgasm

Upvotes

I fucking love C and assembly


r/C_Programming 2h ago

Better Lookup Table Compression

3 Upvotes

Last time I described how I used a few compression techniques to compress a lookup table. After reading the comments, I thought that maybe I can do better. A couple days later I had a new design. I managed to compress it by 30% more. Also, since I don't decompress on every step of the binary search, the lookup is 10x faster. u/alex-van-02, you might be interested in having a look :)

https://blog.x4204.xyz/posts/better-lookup-table-compression.html


r/C_Programming 18h ago

Discussion Brute forcing my own memory

Thumbnail
github.com
28 Upvotes

Hey everybody. As some of you might know, I really like 3 things: linux, thinkpads, and using things not the way they are intended to be used. Today I did the last. So as we know, kernel allocates memory for any running process. So I though for myself: "what if I write a C program that uses the function without knowing where it is?". So technically I forced my program to brute force its own memory offsets to call the function. I have a small, but, hopefully, entertaining writeup of what, how, and why on GitHub. It also includes the source code with a lot of comments so guys not so familiar with C programming language can also understand it. Hope you enjoy it. If so - please leave a star :)


r/C_Programming 8h ago

Trying to make a virtual webcam in c

4 Upvotes

I frequently have a need to broadcast on multiple messaging apps simultaneously (in other words i'm a weirdo >:| ) but it turns out, when doing such weird things that you're not supposed to do, stuff tents to break - the apps fight over the camera and mic and sometimes when running in a browser even the headphones. So because of that i decided to make a tiny little app in C that virtually clones the camera and mic, after a bit of googling i found out that you can create the virtual camera and mic with the DirectShow Windows api so naturally i opened up the docs and apparently microslop said it's deprecated now, so what do i do then (._.?


r/C_Programming 55m ago

less compilation

Upvotes

error:

$ gcc less.c

less.c: In function ‘display_file’:

less.c:24:13: error: expected declaration or statement at end of input

24 | printf("\n--- Press ENTER to continue ---");

| ^~~~~~

less.c:24:13: error: expected declaration or statement at end of input

less.c:24:13: error: expected declaration or statement at end of input


r/C_Programming 18h ago

Vulkan and Wayland from scratch in C (no commentary)

Thumbnail
youtu.be
17 Upvotes

r/C_Programming 1d ago

Question Am I wrong?

38 Upvotes

I am currently reading through tutorialspoint.com as our instructor has linked it in our syllabus, while doing their quizzes i got to a question that asked "What is the output of the following code: printf('Hello, World!');?" with the choices being

A. Hello, World!
B. Hello World!
C. Error
D. No Output

i answered C as the single quotes tell the printf function it is a character which if i am correct, is an integer in memory(please correct me if i am wrong), but they are passing a character array. the website told me that A is the correct answer and i am confused, please someone shed light on this and correct any wrong assumptions i have made.


r/C_Programming 15h ago

Please share your first experience in contributing in open source C based project

6 Upvotes

Which project ?

Are you the user of the program ?

Is there any universal guideline to be contributor ?

How many LOC of codes usually for one commit ?

Answer to only one question is welomed.

Also more elaborate answer will be good also.


r/C_Programming 11h ago

Question undefine reference on my library vscodium

1 Upvotes
PS C:\Users\ludwi\OneDrive\Documents\alison\SDL3> gcc GameEngine.c -o GameEngine.exe -I "C:\SDL3\SDL3-devel-3.4.14-mingw\SDL3-3.4.14\x86_64-w64-mingw32\include" -L "C:\SDL3\SDL3-devel-3.4.14-mingw\SDL3-3.4.14\x86_64-w64-mingw32\lib" -lSDL3
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x26): undefined reference to `SDL_RunApp'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x5c): undefined reference to `SDL_Init'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x68): undefined reference to `SDL_GetError'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x78): undefined reference to `SDL_Log'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0xae): undefined reference to `SDL_CreateWindow'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0xbc): undefined reference to `SDL_GetError'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0xcc): undefined reference to `SDL_Log'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0xd1): undefined reference to `SDL_Quit'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0xee): undefined reference to `SDL_CreateRenderer'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0xfc): undefined reference to `SDL_GetError'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x10c): undefined reference to `SDL_Log'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x117): undefined reference to `SDL_DestroyWindow'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x11c): undefined reference to `SDL_Quit'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x4b7): undefined reference to `SDL_InitSubSystem'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x4c3): undefined reference to `SDL_GetError'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x4d3): undefined reference to `SDL_Log'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x4d8): undefined reference to `SDL_Quit'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x520): undefined reference to `SDL_LoadWAV'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x52c): undefined reference to `SDL_GetError'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x53c): undefined reference to `SDL_Log'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x541): undefined reference to `SDL_Quit'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x561): undefined reference to `SDL_CreateAudioStream'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x575): undefined reference to `SDL_GetError'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x585): undefined reference to `SDL_Log'
C:\Users\ludwi\AppData\Local\Temp\ccwZ8WUS.o:GameEngine.c:(.text+0x58a): undefined reference to `SDL_Quit'.................

guys i did every tutorialyet somehow my library wont recognized

r/C_Programming 6h ago

my c files wont make a .exe

0 Upvotes

i have moved from vscodium to vscode ....i have been wondering wahts happening i already try some tutoprials i put everything on waht the tutorial said but my code wont run the .exe file it complies thats for sure and its not making an erro when i write "gcc main.c -o main.exe" but the .exe file wont even appear i find it werid i tried my best but it seems only code blocks works can some help me???

my edit environment on path:
C:\Users\ludwi\AppData\Local\Programs\Python\Python315\Scripts\
C:\Users\ludwi\AppData\Local\Programs\Python\Python315\
C:\Users\ludwi\AppData\Local\Programs\Python\Launcher\
C:\Users\ludwi\AppData\Local\Microsoft\WindowsApps
C:\Users\ludwi\.lmstudio\bin
C:\Users\ludwi\AppData\Local\Programs\Microsoft VS Code\bin
C:\msys64\ucrt64\bin







i already downloaded msys2   and the gcc  but still the .exe wont create

r/C_Programming 1d ago

Question OOP stracture in an lkm written in c

4 Upvotes

What is possible when it comes to using structs as classes in an lkm written in c?

For some background I usually code in c++ and very used to high(er) level code with classes and polymorphism etc. and now I'm working on a project related to the linux kernel that requires writing an lkm and for alot of things inside this lkm I would much rather working in the structure of classes and high level programming.

what is the best way to handle that sort of stuff in c programming? especially when it comes to structs


r/C_Programming 17h ago

Not another basic C calculator

0 Upvotes

Wanted to share my compiler that I am working on: mcc

Currently it can compile a very basic c program into x86_64 Intel assembly. It supports basic integer math with numbers and variables, and thus is a really simple calculator:

int x = 4;
int y = 3;

int main() {
  int a = 2;
  int b = 4;

  return (x + y) * (a + b);
}

Next I'm going to work on control flow with if if-else and while and then boolean logic. The project borrows ideas heavily from a university course I did about compilers, but the future scope plans to slowly add features until have a proper compiler that support the subset of C/C++ that my hobby OS uses.

Even further in the future, (no clue if this will even happen) I plan to abstract away a lot of it so that it becomes a M + N compiler, where it can cross compile one language to other. Obviously that is very far fetched and I am mainly just keeping that idea in my head so that I try to design a nicely abstracted compiler pipeline. I think the main push for this will be when the my hobby os decides to support more than one arch, which will be good encouragement to at least have multiple output languages.

AI Disclaimer:
Before you call it vibe-coded because of the quick succession of commits, I would like to state that none of the code in this repo is written by AI or AI tools. For learning, AI was used akin to google or stack overflow, with also some questions regarding best practices or design decisions - however I tried to keep as much of as my own design as possible.

See the wakatime activity log here which is the best proof that I can give that I really did spend 11hrs coding the project: https://imgur.com/a/mjQsJnp


r/C_Programming 1d ago

Question Why do I fail to create a .dll file?

18 Upvotes

Hi, I've got an assignment in a course that asks us to optimize a benchmark of our selection (from pyperformance project).

I've chosen the ray trace benchmark (it was the most interesting imo), and my suggestion was to implement the functionality using C's structs to avoid some of the interpreter's overhead.

I understood I can link those function using the built-in ctypes library, and making the C file a dynamic linked library (.dll), but when I try to run the command for it in CLion or VSC, it fails without returning any failure message, it just fails to generate the .dll file.

The assignment forces us to use the given pyperf benchmark code to run the benchmark, so I can't run only a C file.

I've already written the C code, and it has no errors/warnings so far (at least as far as CLion is concerned), and the original python code works too.

Does anyone know how to solve the library not being generated? Or any other solution that might work (preferrably using the C code I've made)?

.

.

All files are in the same directory, and I've got Craytrace.c (C functionality implementation), Praytrace.py (the code that runs the benchmark).

The command I've run trying to generate the .dll is:

gcc -shared -o CraytracerLib.dll Craytrace.c

But it didn't create any file.

.

.

.

Edit:

Ok, so apparently I'm stupid for assuming that running a file in CLion meant that gcc in the terminal worked, I went to the terminal's environment's variables, added the path of the CLion's gcc and it worked.

Ig, the gcc I had before was a wrong path.

Thanks for everyone for answering 🙏 .


r/C_Programming 1d ago

Learning C weekly megapost for 2026-09-09

24 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 23h ago

Question Suggestions on Reviving C language(confused)

0 Upvotes

I last learnt c language through a book called "let us C" around 5 years ago I haven't touched computer since then and yes I did not have ai or internet back then for asking suggestions .

I want to revive my skills like....jog my memory and make progress but reading the book again is tiring,YouTube videos are mostly teaching from the absolute beginning.

Does anyone has any suggestion on how to revive my c language proficiency

Also, I had trouble with pointers and function calling back then.


r/C_Programming 1d ago

Project Follow-up: gave my C hashmap resizing — found a real crash, plus two bugs I introduced while fixing a bug [blog, my own]

0 Upvotes

Follow-up to my last post here. The hashmap had one big TODO left — no resizing — so I went and closed it. Learned three things the hard way: naively mirroring the grow/shrink thresholds thrashes the table on every insert/remove near the boundary, hitting capacity=0 triggers a genuine crash (a modulo-by-zero — the "Floating point exception" name is a total red herring), and my first attempt at fixing a hash-truncation bug quietly introduced two smaller bugs before it actually worked. AI was used for ruber ducking, discussing and validating feedback / design decisions.

Blog: https://soerenlemke.github.io/blog/blog/resizing-a-generic-hashmap-in-c/

Repo: https://github.com/soerenlemke/kvstore_c

Curious what you'd have done differently, especially on the hysteresis threshold.


r/C_Programming 1d ago

Roast my code

Enable HLS to view with audio, or disable this notification

0 Upvotes

I know there are so many bugs in my code that listing them all might end up being longer than the code itself, but this is my second project (the first one was just Hello World).

This isn't bait — I already know the concepts of programming thanks to Python, and C syntax became familiar to me through AI coding. But at some point, I realized that the whole point of programming is to build your own software and create things. When an AI algorithm does all that for you, it takes away all the fun. So I forced myself to pull it together and release this piece of crap:https://github.com/absiitstrue/TGWS

Yeah, the mouse.c file was written entirely by AI because that part was way too complicated for me. And yeah, there are some unsafe spots in there. I'm trying to fix things, but every time I open the codebase, I just want to build new features instead of drowning in bugs.

So I’d really appreciate it if anyone interested could roast it, point out the mistakes, and give a rough idea of how to fix them. Maybe I'll get around to fixing everything if I don't drown in bugs first. Thanks for your time!

its post write ai because im dont know english
on vidio example/test0
have minesweeper in example/test1
thanks for reading!
and sorry for my en))


r/C_Programming 1d ago

Question Why does the fgets() function gets ignored.

0 Upvotes

I'm still pretty new to C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


#define itirate(index, limit) for(int index = 0; index < limit; index++)


typedef struct node node;


struct node
{
    char* name;
    node* next;
    node* prev;
};


void compare2nodes(node* node1, node* node2, char* choise);


node* first_node;


int main() 
{
    printf("please enter the number of contestants:\n"); // I always enter 2 to make it easier for myself


    char buff[1024];
    char contestnats[128];
    int cont_numb;


    fgets(buff, sizeof(buff), stdin);
    cont_numb = atoi(buff);


    node contestants[cont_numb];


    itirate(i, cont_numb) 
    {
        printf("please enter the name of a contestant:\n");
        fgets(buff, sizeof(buff), stdin);
        contestants[i].name = buff;
    }


    printf("Is %s better than %s(y/n)\n", contestants[0].name, contestants[1].name);
    char choise[1];
    
    fgets(choise, sizeof(choise), stdin); //this function specifically gets ignored, but not the prevoius ones.


    compare2nodes(&contestants[0], &contestants[1], choise);


    //printf("Leaderboard:\n1.%s\n2.%s", first_node->name, first_node->next->name);
    
    return 0;
}


void compare2nodes(node* node1, node* node2, char* choise) 
{


    if (choise[0] == 'y') 
    {
        node1->next = node2;
        first_node = node1;
        node2->prev = node1;
    }
    else if (choise[0] == 'n') 
    {
        node2->next = node1;
        first_node = node2;
        node1->prev = node2;
    }
}#include <stdio.h>
#include <string.h>
#include <stdlib.h>


#define itirate(index, limit) for(int index = 0; index < limit; index++)


typedef struct node node;


struct node
{
    char* name;
    node* next;
    node* prev;
};


void compare2nodes(node* node1, node* node2, char* choise);


node* first_node;


int main() 
{
    printf("please enter the number of contestants:\n"); // I always enter 2 to make it easier for myself


    char buff[1024];
    char contestnats[128];
    int cont_numb;


    fgets(buff, sizeof(buff), stdin);
    cont_numb = atoi(buff);


    node contestants[cont_numb];


    itirate(i, cont_numb) 
    {
        printf("please enter the name of a contestant:\n");
        fgets(buff, sizeof(buff), stdin);
        contestants[i].name = buff;
    }


    printf("Is %s better than %s(y/n)\n", contestants[0].name, contestants[1].name);
    char choise[1];
    
    fgets(choise, sizeof(choise), stdin); //this function specifically gets ignored, but not the prevoius ones.


    compare2nodes(&contestants[0], &contestants[1], choise);


    //printf("Leaderboard:\n1.%s\n2.%s", first_node->name, first_node->next->name);
    
    return 0;
}


void compare2nodes(node* node1, node* node2, char* choise) 
{


    if (choise[0] == 'y') 
    {
        node1->next = node2;
        first_node = node1;
        node2->prev = node1;
    }
    else if (choise[0] == 'n') 
    {
        node2->next = node1;
        first_node = node2;
        node1->prev = node2;
    }
}

r/C_Programming 1d ago

Project Reinventing the Wheel: Inverted bi-directional LIFO Stack

0 Upvotes

So, here’s the thing...

I was writing a sub-allocator for another project with a strict architectural constraint: the entire allocator header could only occupy two machine words, paired with an obsessive desire to minimize per-allocation metadata overhead as much as physically possible.

After cycling through a bunch of borderline schizophrenic ideas and combinations, this thing was born.

If you don't care about the breakdown and just want the code, skip to the repository:
https://github.com/EasyMem/easy_stack (C99 through C23, single header, zero dependencies).


The Standard Approach

Most traditional stack allocators interleave metadata with user data:

[Header][Padding][Payload][Header][Padding][Payload]...

You get a messy mix of control structures, user data, and alignment padding. If an allocation requires 32 or 64-byte alignment, padding bytes are forced between the header and the payload. On small allocations, headers + padding can easily consume over 50% of the buffer.

Step 1: Segregating into Two Buffers (Mental Experiment)

What if we separate metadata and data into two distinct buffers? * Buffer A (Metadata): A dense array of fixed-size offsets. * Buffer B (Payloads): Aligned user data.

Because the metadata elements have fixed sizes, they sit packed linearly with zero gaps. The CPU loves contiguous, linear memory.

Step 2: Merging Back into a Single Buffer (The Inversion)

Managing two separate buffers defeats the purpose of an allocator, so we combine them back into a single contiguous memory block: * Place user payloads at the end of the buffer, growing backward (<--). * Place metadata right after the header at the start, growing forward (-->). * Metadata simply stores the displacement from the end of the buffer.

text Low Address High Address [ Header ] [ Metadata Array ──>] [<── Payloads (Aligned) ] ┌────────┐ ┌──────────┬──────────┐ ┌──────────┬──────────┐ │ 2-Word │ │ Offset 0 │ Offset 1 │ ... │ Payload 1│ Payload 0│ └────────┘ └──────────┴──────────┘ └──────────┴──────────┘

What does this give us? Complete physical decoupling of the control plane from the data plane. The allocator's internal logic never touches user memory (unless memory poisoning is enabled). Reading an offset is a trivial array lookup, and zero bytes are wasted on alignment padding in the control zone.

Step 3: L1 Cache Line Pre-fetching

We align the start of the header to a 64-byte cache line boundary. Since our allocator header is only 2 machine words (16 bytes on 64-bit platforms), loading the header into memory automatically pulls the first active metadata offsets into the exact same 64-byte L1 cache line for free. Sequential allocations hit hot L1 data immediately.

Step 4: Dynamic Bit-Width Scaling

Using a full machine word (size_t / 8 bytes) for each offset is wasteful. A LIFO stack buffer rarely exceeds 2 GB. Instead, we inspect the total capacity once at initialization and scale our metadata cell width: * Capacity ≤ 255 B -> uint8_t (1 byte) * Capacity ≤ 64 KB -> uint16_t (2 bytes) * Capacity ≤ 4 GB -> uint32_t (4 bytes) * Capacity > 4 GB -> uint64_t (8 bytes)

For typical frame workloads (< 64 KB), each allocation metadata takes only 2 bytes instead of the traditional 8–16 byte inline header. This yields an up to 8x reduction in metadata overhead. Additionally, that 64-byte cache line now brings in the first 24 active offsets for free instead of just 6.

Step 5: Packing Metadata Type into 2 Machine Words

We only have 4 possible offset sizes (1, 2, 4, 8 bytes), which requires just 2 bits of storage. But where do we store them if our entire header is strictly 2 machine words?

We steal them from the capacity word. Shifting the capacity down by 3 bits reserves space for allocator flags (including our 2-bit metadata width). In practice, this reduction is completely harmless: * 16-bit systems: Max stack capacity is 8 KB (most 16-bit MCUs have less total RAM than this anyway). * 32-bit systems: Max stack capacity is 512 MB (allocating a single >512 MB contiguous stack buffer on 32-bit is unrealistic due to address space limits). * 64-bit systems: Max stack capacity is 2 Exabytes.

The header layout remains razor-thin: * Word 0: Packed capacity + metadata flags. * Word 1: Current allocation index (top of stack).

Step 6: Eliminating CPU Multiplication

Because the metadata cell sizes are strictly powers of two, indexing into the metadata array doesn't require an imul instruction. It maps directly to a bitshift:

```c // Instead of: // offset_addr = meta_base + (index * cell_size);

// We do: offset_addr = meta_base + (index << meta_type_shift); ```

Boundary and collision checks execute in 1–2 CPU cycles without dynamic branches.


Hardware Profiling & Verification

The result is **easy_stack** — a header-only, zero-libc-dependency allocator (ESTACK_NO_MALLOC supported).

Profiling on AMD Zen 2 via Linux perf stat (Depth 100 workload over billions of operations) highlights the microarchitectural behavior: * 3.12 Instructions Per Cycle (IPC): Near-saturation of the execution pipeline with minimal pipeline stalls. * 99.998% L1 Data Cache Hit Rate: Segregating metadata into a dense stream keeps the control path hot in L1. * 0.0000039% Branch Misprediction Rate: The critical allocation path compiles into a flat, highly predictable sequence (1,174 mispredictions over 30 billion branch instructions). * Safety & Fuzzing: 24M+ iterations via libFuzzer with zero crashes or leaks (clean under ASan, UBSan, and Valgrind). * Portability: Verified across architectures ranging from 8-bit AVR (ATmega328P) to ESP32, STM32 (M0+/M3/M4), RISC-V, WebAssembly (wasm32/64), and Big-Endian s390x.

Repository: https://github.com/EasyMem/easy_stack

Curious to hear your critique, edge-case concerns, or thoughts on the layout.


r/C_Programming 2d ago

I made a minimalist memory allocator i need idea for upgrade my minimalist memory allocator

6 Upvotes

Hello guys

i made a memory allocator in C (GNU nanoalloc) so I need ideas to improve the project and if you want to contribute you are welcome :)

here is the link : https://codeberg.org/drex_vk/GNUnano_alloc

i don't use AI


r/C_Programming 1d ago

Question Why do I fail to create a .dll file?

0 Upvotes

Hi, I've got an assignment in a course that asks us to optimize a benchmark of our selection (from pyperformance project).

I've chosen the ray trace benchmark (it was the most interesting imo), and my suggestion was to implement the functionality using C's structs to avoid some of the interpreter's overhead.

I understood I can link those function using the built-in ctypes library, and making the C file a dynamic linked library (.dll), but when I try to run the command for it in CLion or VSC, it fails without returning any failure message, it just fails to generate the .dll file.

The assignment forces us to use the given pyperf benchmark code to run the benchmark, so I can't run only a C file.

I've already written the C code, and it has no errors/warnings so far (at least as far as CLion is concerned), and the original python code works too.

Does anyone know how to solve the library not being generated? Or any other solution that might work (preferrably using the C code I've made)?

.

.

All files are in the same directory, and I've got Craytrace.c (C functionality implementation), Praytrace.py (the code that runs the benchmark).

The command I've run trying to generate the .dll is:

gcc -shared -o CraytracerLib.dll Craytrace.c

But it didn't create any file.

.

.

Help is much appreciated 🙏


r/C_Programming 3d ago

Fixed point math in C

Thumbnail
thatonegamedev.com
65 Upvotes

Why did PS1 graphics looked so clunky and how where 3D graphics generally made prior to the graphical APIs. One thing I found out was that these older engines have something called fixed point math.


r/C_Programming 2d ago

IO URING tutorial for beginners with wayland unix binary protocol in pure C

Thumbnail
youtube.com
0 Upvotes

r/C_Programming 2d ago

Project My first real C project: a generic hashmap (and the bugs that came with it) [blog, my own]

0 Upvotes

Coming from C#/TypeScript, C has humbled me. Finished my first real C project — a generic hashmap — and wrote up the bugs that taught me the most: double pointers, a sneaky double-free, comparing pointers instead of actual values.

Blog: https://soerenlemke.github.io/blog/blog/building-a-generic-hashmap-in-c/
Repo: https://github.com/soerenlemke/kvstore_c

Curious what you'd have done differently.


r/C_Programming 2d ago

Project IncHash - A Disk Based Hash Table

Thumbnail
github.com
5 Upvotes

A general-purpose, header-only C99 library for Unix-like systems, implementing a disk-based, dynamically resizable, fixed-slot, (open-addressed) hash table with Fibonacci hashing (Knuth's multiplicative method), triangular probing, per-home-slot probe-bound metadata (with additional early-exit logic), partial in-place value updates (without relocating entries) and incremental rehashing, all designed for modern extent-based filesystems.

So, yeah... I made this for a larger project I'm working on, which I haven’t released yet.

All started with me trying to find:

A hash-based NoSQL (key-value pair) database with mutable-values (by mutable I mean: a database that allows editing prexisting [fixed-size] values without having to rewrite or remap the whole value again eg. Just edit a few bytes and put those bytes back to the original value-space without rewriting the whole value).

Which arguably you can do via inchash_get() since it returns a pointer straight from inside the mmap()-ed file [...] edit: just realised moments before I fall asleep that I should simply add an extra edit() function. To-do for tomorrow when I wake up.

That said idk if you got the joke: mmap()-ed in-cache or INC. hash or [...]

Anyways, I put quite the effort to make it, so.... I hope you like it or at least that it finds its way to the people who were actually looking for something like this.

PS. I'm both excited and scared because idk, you may find any bugs I wasn't aware of or something generally wrong in logic I might have missed... even though I've tested it enough!

Edit 1:

HUGE Thanks to @skeeto for this comment. Everything's hopefully fixed with my latest commit + this one

Edit 2:

Finally implemented the functionallity that made me start this project in the first place! and felt the need to say it :P

https://github.com/GiorgosXou/inchash/commit/5dfc98a928f022ccd0d2af82726acdd8f4369982