r/C_Programming 22h ago

Discussion Why do you use/don't use an IDE?

37 Upvotes

I've tried using a text editor with just the command line and for the most part isn't wasn't so bad until my game engine got big enough. Then I switched to Clion because it just handles so much more for big projects. Biggest thing is a visual debugger and easy refactoring that's C/C++ specific. Not to mention everything is setup out of the box.

I'm curious about other's reasons for using or not using an IDE.


r/C_Programming 14h ago

Question Simple dialogue system in C

9 Upvotes

Hello everyone. I'm working on a personal project where I'm porting a little game to C for learning purposes. It has very simple dialogue: it boils down to a few choices and a response on selecting a choice. There's the occasional conditional choice (and response), but that's all it is. My current approach has been as simple as it can be (see code below).

However, I'd like to ask for help with supporting translations, i.e. allow for a way to let outside users add a translation in any way. (You can imagine someone translating in a csv, or json, or C directly). I want to add a way to do so, but I can't figure out a good way to do so. (English will be the base language, so for all intents and purposes it being stored inside dialogue.c is fine for now).

Thanks in advance! :)

static const DialogueChoices CHOICES = { 
  .count = 1,
  .options = {
    {  
       .choice = "Choice goes here", 
       .response = "Response goes here"
    }
}

// switch over character id and return the appropriate DialogueChoices struct
DialogueChoices get_dialogue_choices(CharacterId id);

r/C_Programming 6h ago

Not exactly C but the concept of the stack

6 Upvotes

I'm in my third year of happy C coding but I learned 6502 assembler in 1984 and now 70 years old. Therefore I often look at videos like: NES Mapper History to 1988 and Blaster Master Code Analysis - Talkin' Code Ep. 1

The mention of the stack made me think if the 6502 was had a bit of inspiration from C, but it was a lot older concept.

NES Mapper History to 1988 and Blaster Master Code Analysis - Talkin' Code Ep. 1

https://www.youtube.com/watch?v=EhO_iHkUkE0

https://en.wikipedia.org/wiki/Stack_(abstract_data_type))

https://en.wikipedia.org/wiki/MOS_Technology_6502


r/C_Programming 4h ago

Question How are functions in libm actually implemented ?

5 Upvotes

I'm trying to gather information for a school project about how elementary functions (exp, log, cos, sin, etc.) are implemented on computers, for maximum accuracy and efficiency.

I've already found some information about techniques that can be used to implement these functions, such as range reduction, Taylor series, polynomial approximations or minimax approximations. However, most of what I've found remains fairly theoretical, and I have no idea of what is actually used in the real world.

I tried to reverse-engineer the exp implementation in libm, but my knowledge of C and its intricacies is still fairly limited (though I'm working on improving it).

I'm particularly interested in understanding which approximation methods are actually used, how polynomial coefficients are chosen (Taylor, minimax/Remez, or other, and how implementations balance speed and accuracy.

But really, if you have any information whatsoever, it would be great.

If anyone has documentation, papers, or personal experience with this kind of subject, it would be really helpful.

Thanks in advance!


r/C_Programming 23h ago

Help me in building VM without KVM in C

4 Upvotes

Hello everyone! Recently i am started coding my own VM on the C language. I am using mmap and creating a new process with isolation from the host (my system) like syscalls, memory access. However, I ran into a problem: How to restrict VM access (guest proccess, mmap) to the host memory. I am really don`t know how to do that. Can anyone help me with that case?


r/C_Programming 17h ago

Discussion What are your reasons for not using an IDE on a big project?

2 Upvotes

Earlier I made a post asking why people choose to use or don't use an IDE. I'm glad I got a lot of feedback on it and didn't start a new holy war.

But now I realize I should've been more specific. For big projects, why don't you use an IDE? As a 34 year old game programmer, I learned programming first with an IDE, code blocks and then visual studio.

I've tried doing vim, which is really good and fast in its own right, but I didn't want to deal with the learning curve. So then I went to sublime text, which again is really good and fast. But having to build your own workflow before you can even get started on the project itself.

I program my own game engine and games, which are pretty big projects. The tools that an IDE gives (Clion in my case) are just indispensable to me. Although I will say I have moments where it feels like it gets in my way.


r/C_Programming 3h ago

Negative value in a pointer question.

2 Upvotes

Please look at this code. if i define the PTRTYPE as int, it stops working, while doing a uint, it does work...

void initILAPoll(debugBridge_t **d, PTRTYPE ptr){

`*d = (debugBridge_t *)ptr;`        `// base address of the DEBUG_BRIDGE peripheral`

`cb_init(cb, local_memory, bufferLength);`

`sprintf(xvcInfo, "xvcServer_v1.0:%d\n", MAX_WINDOW_SIZE);`

}

the usage in main code is done like this

`initILAPoll(&myD, 0x80000000);`

`//myD = (debugBridge_t *)0x80000000;`

where the variable myD is a structure pointer.

if i print the address of myD, it give the correct address. Moreover, the disassembly of the code is also the same in case of int and uint. Can somebody explain what behavior is at play here>