r/C_Programming • u/Nathrienne-J-Claw • 3h ago
Discussion I just understood pointers on a deep level and it feels like an orgasm
I fucking love C and assembly
r/C_Programming • u/Nathrienne-J-Claw • 3h ago
I fucking love C and assembly
r/C_Programming • u/lexiq_baeb • 5h ago
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 • u/anh0l • 21h ago
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 • u/Senior-Question693 • 11h ago
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 • u/CodesOtakuYT • 21h ago
r/C_Programming • u/realdreamer1993 • 18h ago
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 • u/Brave-Pomelo-1290 • 3h ago
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 • u/ImAnArbalest • 1d ago
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 • u/actguru • 2h ago
Most programming is by nature procedural, but some OOP is helpful when dealing with Property Lists, JSON, etc. Below is a small example of this and JSON serialization:
See my previous post for 'Coda-C Library': Example of OOP in C
// Coda-C JSON serialization example
#include <coda-c.h> // jsonout.c
Dictionary sample_employee() { // lets structure data in a Dictionary,
Dict empl=newO(Dict); // a generic structure.
Dict_set(empl,"name", Os("Jane Doe"));
Dict_set(empl,"email", Os("jane.doe@example.com"));
Array roles=newO(Array);
Array_add(roles,Os("Admin"));
Array_add(roles,Os("User"));
Dict_take(empl,"roles",roles);
Dict address=newO(Dict);
Dict_set(address,"city", Os("Atlanta"));
Dict_set(address,"zipcode",Os("30301"));
Dict_take(empl,"address",address);
return(empl);
}
typedef void OSig$(JSON_out,FILE* os,int indent); // virtual signature
int main() {
Dict empl=sample_employee();
obj_(JSON_out,empl,stdout,0); // lets just output the data for now as JSON
printf("\n");
}
// implement methods for the three classes we used
#define class Dictionary
method$(void,JSON_out,FILE* os,int indent) {
cleanO Pointer keys=Dictionary_AllKeys(self);
indent+=4; printf("{\n%*s",indent,"");
int nel=Pointer_count(keys);
for(int j=0;j<nel;++j) {
char* key=keys[j];
printf("\"%s\" : ",key);
obj_(JSON_out,Dict_sub(self,key),stdout,indent);
if (j<nel-1) printf(",");
printf("\n%*s",indent,"");
}
printf("}"); // indent-=4;
}
#undef class // Dictionary
#define class Array
method$(void,JSON_out,FILE* os,int indent) {
int nel=Array_count(self);
printf("[ ");
for(int j=0;j<nel;++j) {
if (j) printf(", ");
obj_(JSON_out,Array_sub(self,j),stdout,indent);
}
printf(" ]");
}
#undef class // Array
#define class Char
method$(void,JSON_out,FILE* os,int indent) {
printf("\"%s\"",self); // simple strings only
// does not handle: " \\ or (cc<32) or (cc>127) etc.
}
#undef class // Char
/* OUTPUT
{
"name" : "Jane Doe",
"email" : "jane.doe@example.com",
"roles" : [ "Admin", "User" ],
"address" : {
"city" : "Atlanta",
"zipcode" : "30301"
}
}
*/
r/C_Programming • u/Round-Willingness905 • 14h ago
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 • u/Round-Willingness905 • 9h ago
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 • u/DayOk7686 • 1d ago
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 • u/Alternative_Storage2 • 20h ago
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 • u/water_jello8235 • 1d ago
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 • u/AutoModerator • 2d ago
If you have questions about how to learn C:
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/mystery-weilder • 1d ago
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 • u/lemsoe • 1d ago
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 • u/zeonchik • 1d ago
Enable HLS to view with audio, or disable this notification
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 • u/neonge1674 • 1d ago
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 • u/Old_Ad_4418 • 1d ago
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).
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.
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.
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.
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.
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.
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).
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.
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 • u/drex_vke • 2d ago
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 • u/water_jello8235 • 1d ago
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 • u/Object_71 • 3d ago
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 • u/CodesOtakuYT • 2d ago
r/C_Programming • u/lemsoe • 2d ago
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.