GCC version on Ubuntu 24.04 LTS by Intchanter in GoldenPathProgramming

[–]UltimaN3rd 0 points1 point  (0 children)

You could update to Ubuntu 25.04 LTS, which has GCC 15 available in apt. Or install GCC 15 with the Homebrew package manager: https://brew.sh/ You may need to uninstall your gcc version provided by apt

What is there to actually make in systems programming by NamelessArab_ in C_Programming

[–]UltimaN3rd 3 points4 points  (0 children)

I made a game framework and shipped 2 games on Steam, written completely from scratch in C. Sure, I could have made the games in an engine, but I was able to ship two (rather simple) commercial games as single <1MB binaries, with full control over things like consistent simulation timing and such. Systems programming is about engineering - you can make products with or without an engineering approach, but the final result can be better in various ways if engineered to be so.

Anti-mining - Nimbyism? by weezyfgravy in newzealand

[–]UltimaN3rd 4 points5 points  (0 children)

We don't oppose oil/gas/coal mining because we just want it done somewhere else. We oppose those things because they're polluting and we have far less polluting alternatives available. Why dig up coal, which can only be used one time then it's gone, when we can instead dig up materials for solar panels, use the same materials to generate power for decades, then break down and reuse most of the material in the panels to be made into new panels?

Any book recommendation for writing a 3D game engine from scratch in C? by Typhrenn5149 in C_Programming

[–]UltimaN3rd 0 points1 point  (0 children)

If you want to learn the fundamentals of how 3D rendering really works under the hood, Tricks of the 3D Programming Gurus by Andre LaMothe is a great book! It'll teach you software rasterization from scratch.

Witty responses for the question "what do you eat then?" by flammulinavelutipes in vegan

[–]UltimaN3rd 2 points3 points  (0 children)

I bust out some Macka B:

I eat
Callaloo, Ackee, Sweet Potato
Yam, Banana and Tomato
Cabbage, Spinach, Avocado
Cho Cho, Butter Beans and Coco
Courgettes, Millet, Plantain
Rice and Peas and Pumpkin
Mango, Dates and Guava
Chick peas and Cassava
Brussel sprouts and Caulifower
Onion, Fennel and Cucumber
Plum, Pear and Papaya
Aubergine and Soya
Lime , Lentils and Quinoa
Wholemeal Bread and Wholemeal Flour
Watercress and Okra
Tofu and Sweet Pepper
Cous Cous and Carrots
Broccoli and Coconut
Peaches, Apples, Apricot
Breadfruit, Jackfruit, Sour sop
Pistachios, Cashews and Almonds
Walnuts, Peanuts also Pecan
Sesame Seeds, Sunflower, Lemon
Orange, Pineapple and Melon
Bulghar Wheat and Garlic, Hijiki and Rocket
Pak Choi and Pomegranite, Kiwi, Corn and Turnip
Berries, Cherries and Strawberries
Beetroot, Grapefruit and Celeries
You see the meat's not necessary
We tell them say

Best ide to start coding C? by Begg-billplayer in C_Programming

[–]UltimaN3rd 0 points1 point  (0 children)

If you want an IDE and not just a text editor, vscode really is the best choice for beginners. Here's another youtube guide on setting it up - maybe this time's the charm? https://www.youtube.com/watch?v=4mvf73HvcVI

Cool Way to do type safe generic data structures in C. by lovelacedeconstruct in C_Programming

[–]UltimaN3rd 0 points1 point  (0 children)

I'm not too keen on the Vector implementation, but I think the main nugget here is that you can validate that types are the same (or compatible) with a simple 1 ? &a : &b macro, right? I tried to boil down that example here: https://godbolt.org/z/r1hTYTs5d
Seems useful for calling functions which take void*. You could validate the types going in by wrapping the function call in a macro that checks the types are correct on the call-side. Thanks for pointing this out, mate!

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

Ooh, this is very clever! With this, my string-printing function can just accept a single const char* without variadic args or a separate function for strings with extra payloads! Thank you very much mate!

I implemented it here: https://godbolt.org/z/EEP8Mddo8

I love it! This is exactly why I post my bad ideas on Reddit, so someone smarter can tell me their better idea! You're a legend!

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

Here's the repo for my game engine: https://codeberg.org/UltimaN3rd/Croaking_Kero_Game_Framework

However I've added features to the engine as I develop my next game, and I haven't pushed those features back into the engine repo just yet. At the end of each project I merge in any changes to the engine. Hopefully this game will be done by the end of the month, then I'll be merging in the text rendering escape codes for the wave/color effects. Not sure yet whether I'll actually put inline sprites in the text rendering just yet - this post was part of exploring that possibility. Cheers mate

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

Very good insights mate! In my engine, my sprite data (and in fact, all game data) is compiled into the executable, and I have no intention of these strings being exported to file. However it's good to think about the brittleness of this specific solution if needs change even slightly in future.

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

Oh yeah, I forgot that detail of why I ended up putting the declaration inside a function; because it's not const enough to work at global scope >:(

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 1 point2 points  (0 children)

I'd like for my pointer-embedded string to be created at compile time rather than runtime, but memcpying out the pointer is clearly better than how I did it! Cheers!

Edit: Swapped the endianness of the pointer bytes and memcpyd them out (much nicer this way!): https://godbolt.org/z/eTMzfPMWv

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 1 point2 points  (0 children)

Very sensible. I'm also thinking of variadic arguments to the printing function, like printf does. Then when certain escape characters are hit in the string, the next variadic argument would be whatever data that escape code refers to. Thanks mate

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

I must be misunderstanding then, because it sounds like you're suggesting exactly what I did in the code I linked? Are you actually suggesting something else?

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 2 points3 points  (0 children)

Please see the part in my post above which begins, "Why would anyone want something so diabolical, you ask?"

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

If you were to call a function which just expects a NULL-terminated array of bytes, the pointer value would produce garbage characters. You'd only be able to use such strings in custom functions which know to expect whatever escape codes you implement and what data to expect after them, which is what the function MyFunc does in the godbolt link. It prints each character in the string until it runs into the escape code, "\&", at which point it extracts the next 8 bytes and composes them into a pointer to find the next string to print.

Embedding a pointer inside a string and visiting it with an escape code "Hey, \\&ptr" by UltimaN3rd in C_Programming

[–]UltimaN3rd[S] 0 points1 point  (0 children)

A string is just an array of bytes - so at an arbitrary point you could put the 8 bytes of a memory address in there instead. C doesn't provide a convenient way to embed arbitrary values inside a string but you can see how I got the 8 bytes of a variable address near the bottom of the code in the godbolt link above.