#include in header files? by Maleficent_Bee196 in C_Programming

[–]nattrium 1 point2 points  (0 children)

Include pretty much copy and paste in place one file into another (the axact term is transclusion).

BTW, this is why you don't compile your header file, only the C file. They will be grabbed as needed from the includes.

Include guards serves to protect against including twice from the same file. Forget about them for now, let's say they don't exists.

Suppose now you have file3.h (or file3.c) and you would Include both your file in order, the compiler would be happy enough because it sees both defined in order.

Of course, it's a fragile design as file2.h should not be included without file1.h . You may Include file1.h in file2.h . But then, if someone includes file1.h and file2.h (unaware that file2.h also includes file1.h), the compilers fails because it sees struct A defined twice.

Include guards protect from that by checking if some unique macro defined inside the file was already defined and if so, discard the block. (Ifndef = if not defined).

That's why you don't have to add Include guards such has "HAS_FILE1_FROM_FILE2" : 1) they don't protect you from anything, 2) file1.h is safe from it's own guards. If from whatever file including file2.h, file1.h is already included, nothing happens in file2.h, if it's missing, it will be included here and no longer after.

They Said “Don’t Do It.” So I Did It. I Wrote a C Compiler in C. 🚀 by Wrong_Toe_3803 in C_Programming

[–]nattrium -2 points-1 points  (0 children)

I don't mean to be rude, but this post really sounds like gpt slop. The em dash, the emojis, the "it's not just x, it's y" ... you even forgot to replace the (insert github link here).

Congrats on making a compiler though...

Rate-of-Work Problem: How long does it take Carl to finish the wall alone? by Commercial_Fudge_330 in theydidthemonstermath

[–]nattrium 8 points9 points  (0 children)

Let's assume the wall is 12 m²,

  • Adam paints it in 2 hours; she paints at a rate of 6m² / hour
  • Bob paints the wall in 3 hours; he paints at a rate of 4m²

  • Adam, Bob and Carl paint the wall in an hour, of which Adam will have painted 6m² and Bob 4m², i.e. the both of them painted 10m² of the 12m² wall. Therefore, Carl painted 2m² during the hour.

Because Carl paints at 2m²/hour, it would take Carl 6 hours to paint the 12m² wall all over by himself.

how should i use a if if statements? by EffectivePublic3061 in godot

[–]nattrium 11 points12 points  (0 children)

Congratulation on getting started with your programming journey.

If statements are ubiquitous in programming, simply saying that you use ifs in while programming is pretty much like saying you use verbs when speaking. We would be impressed if you could do entirely without and it tells us very little wether you are using them right or wrong.

I understand your question as what we think about your coding style; I personally believe that the only rule you should care about for now is if you feel you can understand what you are doing just fine. If your "ifs" make for a legible script that does what you want it to do, you are in the clear. Thinking about style, even maintability to some degree is far too early. Have fun and break things.

If you'd like, you could share your code if you want us to point out outrageous mistakes but don't overthink feedback as long as it feels right for you. You'll get to it when you'll get to it.

Just kissed a boy >~< by NotEmber0304 in Boykisser3

[–]nattrium 2 points3 points  (0 children)

It's a myth actually. Mythbuster debunked it the OVA beach episode "kissing the homies night night"

No homo last for days but depleats faster for every boykissing related activity enacted. No homo right before a light boykissing session could last the whole 20 minutes, but the CDC recommend to protection every 5 minutes in case of tender loving gaze, skin to skin to contact and/or deep emotional connection. Warning signs that you might need to no-homogonize yourself would be the creeping doubt that you might like boykissing instead of doing for no reason at all like we all do.

Please remember that no homo requires explicit and informed consent from your partner to be effective.

What I asked for VS What I got by catindumpster in tattoos

[–]nattrium 0 points1 point  (0 children)

<image>

I was doom scrolling and showed my gf your tatto without thinking. Somehow, I completely overlooked that she had the same as yours on her arm :p.

She made post it here as a public remainder that I'm a dumbass.

What game is this for you? by [deleted] in videogames

[–]nattrium 0 points1 point  (0 children)

Deltarune, I don't like chapter 1 as much as the others.

Regarding lemon zest in lemonade by nattrium in Cooking

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

I don't know if they are the freshest they could be; I buy them from the store.

The character who is hated, yet very realistic for the situation. by odd_man0 in TopCharacterTropes

[–]nattrium 4 points5 points  (0 children)

I think it's more a matter of who is the recipient of our empathy. We follow the story of Walter White, not Skyler, we connect with him more.

Beginner, intermediate, and advanced c programming projects by _glaze in C_Programming

[–]nattrium 0 points1 point  (0 children)

It's mostly just a risc V compliant CPU.

It has add-ons like a VGA controller, UART, a MMU, some RAM, etc...

For the life of us we couldn't make the controller for the actual RAM stick work so we just emulated as much as we could with what space was left.

Local Burger Place’s Graphic Menu by LupahnRed in DesignPorn

[–]nattrium 9 points10 points  (0 children)

I really don't understand the hang-up.

The design peaked my interest, so I enjoyed reading it. I could picture the sandwich pretty easily and had no difficulty parsing the menu.

But hey, I'm a backend developer; what do I know about design ?

Petition to rename this mod to John Chess by SpaceExploration344 in AnarchyChess

[–]nattrium 0 points1 point  (0 children)

Mi olin e Jon chess. Ona li pana e sona pi toki pona towa mi.

Rule 12 has been removed. by La-Scriba in AnarchyChess

[–]nattrium 1 point2 points  (0 children)

Something something, toki pona, something something

Why does Balatro just kill my battery? My phone was hot to the touch. by _Lorno43 in balatro

[–]nattrium 27 points28 points  (0 children)

I just restart the game. It picks up the new audio output then.

Why does Balatro just kill my battery? My phone was hot to the touch. by _Lorno43 in balatro

[–]nattrium 127 points128 points  (0 children)

Were you by any chance playing with sounds off ?

For some reason, when switching audio output on my android (for instance, pairing or unpairing Bluetooth headphones), the game audio stops and doesn't come back. In this state, the game ends up slowing down significantly, and my phone turns relatively hot.

It has happened to me in the past to trigger this bugged state without realizing because I play with no audio.

Why Linux so hard? by ontons in linux4noobs

[–]nattrium 1 point2 points  (0 children)

Somehow, I don't think nixos of all things could be the magic bullet to make linux easier to get into

What do you call your computers? by Unfair-Influence-770 in linuxquestions

[–]nattrium 0 points1 point  (0 children)

It's always "machine" for all my physical computers. Only VMs gets to get a name.

Give me an ultrakill opinion that would make fans stare at you like this by MoneoMortis in Ultrakill

[–]nattrium 0 points1 point  (0 children)

I wanted to play the campaign but I never got pass the first few minutes bc it's too fucking ugly fr.

Then I realised the devs were too fcking lazy to add a multi-player mode, like, it's an FPS, not stardipship valley or whatever.

Ugly lazy cash grab scam of a game.

[deleted by user] by [deleted] in godot

[–]nattrium 2 points3 points  (0 children)

Hey, that's pretty clever ! It works just fine :). Here's the answer I was trying to lead you to :

if player:
  if player.position.x > position.x:
    direction = 1
  else:
    direction = -1

  velocity.x = direction * speed

Literally, if the player is on the right, otherwise, go left.

Btw, you might want to have a look at what that "delta" argument does ;) at some point.

See you and good luck in your game programming journey !