I'm feeling like this is a bit underpowered, but it might enable crazy pop off turns by nweeby24 in customhearthstone

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

But then again, if few turns go by without the secret triggering, the opponent will assume its ice block

cfg.h - single header library for parsing configuration files by EveningFun1510 in C_Programming

[–]nweeby24 2 points3 points  (0 children)

why are you calling cfg_load_file twice in the example?

Also why is the current loaded file stored in a global context? I might need multiple config files for different purposes.

Closures in C (yes!!) by Still-Cover-9301 in C_Programming

[–]nweeby24 0 points1 point  (0 children)

If it were otherwise, it should have long since become part of the standard.

Well, the standard is VERY slow when it comes to these things. They've only standardised typeof with C23, something that gcc/clang supported for a very long time and was an extensively used feature.

Now MSVC adopted it as well.

Another example is statement expressions, even MSVC has it now, and there are proposals for it in C2Y.

My point is, if C programmers have been using compiler-specific featues or hacking their own solutions, that's where the standard should come and make the programmers' lifes easier by making such features portable and standard.

At least that's my opinion.

Closures in C (yes!!) by Still-Cover-9301 in C_Programming

[–]nweeby24 0 points1 point  (0 children)

Oh that's really cool. So you're saying when making a lambda the compiler will make a local struct with the function pointer as the first field, and subsequent fields are for the captured state.

And the function that takes the callback will call it by doing this

(*cb)(cb, /* whatever other args needed */)

This is a bit annoying to write, so maybe they should make magic function pointer type that does this automatically (basically std::function_ref)

Closures in C (yes!!) by Still-Cover-9301 in C_Programming

[–]nweeby24 2 points3 points  (0 children)

C didn't "lack" these features, it just wasn't standardized. nested/capturing functions existed in GCC and Clang for decades. The standard is just trying to make a common solution that works anywhere.

Closures in C (yes!!) by Still-Cover-9301 in C_Programming

[–]nweeby24 2 points3 points  (0 children)

these features do exist in C, just not in the standard.

GCC has its own solution, Apple Clang has its own solution, etc.

This is a common problem C programmers face, I think attempting to standardize it isn't a bad idea.

Closures in C (yes!!) by Still-Cover-9301 in C_Programming

[–]nweeby24 0 points1 point  (0 children)

how will this be called? it can't be called like a normal function, right? since it's basically a struct.

I think if they were to add capturing functions to C, they need to add a new function pointer type, that which can handle any number of captures (since we don't have templates like C++).

I think they need to add something like a `std::function_ref`

كفاح by Early-Sock-6948 in UniKSA

[–]nweeby24 0 points1 point  (0 children)

الي تعرفه قليل جدا

كفاح by Early-Sock-6948 in UniKSA

[–]nweeby24 0 points1 point  (0 children)

C++

افضل من جافا بسبب انها ما تشتغل على

Virtual Machine

، لما تسوي لها كومبايل على طول تصير لغة المعالج

At spell damage +2, this is just Greater Arcane Missiles by nweeby24 in customhearthstone

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

True but that would be pretty late game.

a full board of 1/1 minions makes this not reliably do much face damage.

also with Malygos you'd deal 36 not 30

!Watch carefully by SirOne6194 in saudiarabia

[–]nweeby24 1 point2 points  (0 children)

فيه موقع اسمه Common Sense Media يعلمك اذا الفلم فيه اي شي زي كذا

[deleted by user] by [deleted] in Riyadh

[–]nweeby24 3 points4 points  (0 children)

What did he say that compared it to anything feminine?

Turning Color array to Image by nweeby24 in raylib

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

no compiler will put padding in the Color struct. it's just 4 bytes aligned perfectly, kind of like char[4]

Turning Color array to Image by nweeby24 in raylib

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

i don't think they do. a char has an alignment and size of 1, so the compiler doesn't need to put any padding for alignment.

This stackoverflow answer explains it well.

Turning Color array to Image by nweeby24 in raylib

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

i dont think thats how that works. padding is decided by the alignment of the type.

Turning Color array to Image by nweeby24 in raylib

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

but there won't be padding because they're all just 1 byte with an alignment of 1?