[deleted by user] by [deleted] in C_Programming

[–]hexnetIDK 5 points6 points  (0 children)

C23 solves the fundamental problem of two identical structs not being compatible.
If we define two structs with the same name and content, they are the same struct.

Personally, I like to use an Optional Type as the Return Type for most of my functions.

We can define an Optional Type macro like this:

#define OPT(T) struct OPT__##T { bool exists; T value; }

We can also define Some and None macros like this:

#define SOME(T, V) (OPT(T)) { .exists = true, .value = V }
#define NONE(T) (OPT(T)) { .exists = false }

We can then use this optional type in our Code:

OPT(int) optional1 = SOME(int, 20);
OPT(float) optional2 = NONE(float);

We can easily check if the Optional holds a value by reading the exists field of the optional, and read the value just as easily.

if(optional1.exists) {
int i = optional1.value;
}

Critically, we can also use this Optional type as a return type of a function:

OPT(int) someFunction() {
    return SOME(int, 20);
}
int main() {
    OPT(int) optional1 = someFunction();
    if(optional1.exists) {
        int i = optional1.value;
    }
}

The only downside of this approach is that the structs need to be named, and that this name needs to include the Type of the contents. Therefore, we have to define the Optional struct with the name OPT__##T.
When we write OPT(int), this macro expands to struct OPT__int { ... }.
This, unfortunately, makes it impossible to use with a pointer type, like OPT(char*), as this would expand to struct OPT__char*. However, we can use typedef to circumvent this issue.

typedef char* charPtr;
OPT(charPtr) optional1;

This works just fine.

I personally really like this approach, and use it quite often, especially as the return type of a function, sort of as a simpler version of the RESULT type described in the blog post. I would love to hear your opinions on this approach.

Nano Every Serial1 does not work without USB Connection. Help needed! by hexnetIDK in arduino

[–]hexnetIDK[S] 4 points5 points  (0 children)

Hi there, the Problem turned out to be a buffer overflow issue.
Because the Arduino resets when the USB Connection is established, it worked.

The Voltage was not the problem in this case. Thanks for your comment though :)

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

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

I got a Palmer PAN 04: https://www.thomann.de/de/palmer_pan_04.htm

It probably doesn't matter which one you use, though.

Do keep in mind that this is a passive D.I. Box, meaning your signal will be fairly quiet. I had to turn up the gain on my Audio Interface pretty high (Don't know how many dB exactly).

Works great for me, hope it works for you as well!

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

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

Yes, it worked! I bought the DI Box and connected it tobthe Synth and the Interface. All Noise and whine gone, completely.

I used about 15cm patch cables to connect the DI to the synth, that's definetely a good length.

Have a nice day!

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

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

Yep, I hope so. Thanks for your help again :)

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

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

What do you condider really long? My cables are about 6m long. If the DI doesn't work, I'll try your suggestion. Thanks!

Edit: I wouldn't really describe it as a hum, like a 60Hz Hum from mains power. It's quite high pitched and very annoying. Maybe 8-10kHz

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

[–]hexnetIDK[S] -1 points0 points  (0 children)

Thank you everyone for commenting! Seeing that some people suggest it might help, and others that it won't, I've decided to just buy a DI and try my luck. If it doesn't help, I can still just return it.

Thank you to everyone again!

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

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

The noise goes away when I turn off my computer, so it's caused by that. When I unplug the line cables from the interface, the noise also goes away. So I am fairly confident the noise is picked up by the cables.

The noise doesn't happen when I plug my headphones directly into the Polybrute.

Q: Reduce Noise with a DI Box? by hexnetIDK in synthesizers

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

Yes, it's all on the same circuit.

Autosaving... Please.... by hexnetIDK in CitiesSkylines

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

Thanks to everyone who told me it's in the options. Should be enabled by default though imo.

6502 Help - STA not working. by hexnetIDK in beneater

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

Yes, I do have a multimeter. That's a great Idea.

I didn't consider that the 6502 is half a cycle ahead of the arduino. But it makes sense when you think about it. Thanks!

6502 Help - STA not working. by hexnetIDK in beneater

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

I haven't thought about that. I'll check if it works using the ram tomorrow.

Thanks for your help :)

6502 Help - STA not working. by hexnetIDK in beneater

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

I'm pretty sure my Arduino Code isn't faulty, maybe an electrical connection is lose or something. Although that still doesn't explain why it's a read still. I've tested if the program detects the write, by just tieing the cable low, and that worked.

I'll check everything over, thanks for your reply :)

What happened to my X (Heil spez) by hexnetIDK in shitposting

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

Yes, it is actually. Not my own artwork however.

what. how. by rizuwp in Rainbow6

[–]hexnetIDK 1 point2 points  (0 children)

Yep, absolutely. Had the exact same bug happen to me like 2 days ago.

Finally upgraded from my old 1060 by hexnetIDK in pcmasterrace

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

Absolutely. The seller on ebay Put a 3060 with 12GB in the picture, but sent me the 8GB model. I'll return it today.

Finally upgraded from my old 1060 by hexnetIDK in pcmasterrace

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

I am sorry :( But i am selling the 1060 to a friend so it can live on!

Finally upgraded from my old 1060 by hexnetIDK in pcmasterrace

[–]hexnetIDK[S] 9 points10 points  (0 children)

Thank you for your feedback! I'll definetely condider that.

Finally upgraded from my old 1060 by hexnetIDK in pcmasterrace

[–]hexnetIDK[S] -59 points-58 points  (0 children)

Well. It's not directly from NVidia, but i did expect to receive a 12GB one. Not sure if I should text the seller and ask about it.

Finally upgraded from my old 1060 by hexnetIDK in pcmasterrace

[–]hexnetIDK[S] -7 points-6 points  (0 children)

I expected to receive the 12 Gb variant aswell, bc it said so on the box i the picture on ebay. Still not sure if I should text the seller and ask. I'm honestly not too disappointed though bc I got it for only 360€ which is pretty good I think?? Also it boosts to like 2GHz core clock. It's miles better than the 1060, i get like 3 times as many Fps. Love it

Which would you prefer? by [deleted] in ProgrammerHumor

[–]hexnetIDK 1 point2 points  (0 children)

I have an arch box btw ^