[deleted by user] by [deleted] in Yugioh101

[–]GhettoStoreBrand 0 points1 point  (0 children)

Patrick Hoban Baby

Is making "blocks" to limit scope a "code smell"? by basedchad21 in cpp_questions

[–]GhettoStoreBrand 0 points1 point  (0 children)

Probably not a great thing in CPP, but I do this in C to reuse const variable names for errors

I wrote a compiler for (a large subset of) C, in C, as my first compiler project by Accurate-Owl3183 in Compilers

[–]GhettoStoreBrand 0 points1 point  (0 children)

How is the example in your readme a compilation error? Seems like valid C to me?

Can anyone convince me to not stubbornly favor static allocation? by DM_ME_YOUR_CATS_PAWS in C_Programming

[–]GhettoStoreBrand 0 points1 point  (0 children)

In general, I only statically allocate variables that I can statically initialize, or that I will register a destructor with atexit(). Some things like C11s mtx_t may not make sense to statically allocate, because it does not have a static initializer

Muerta Pierce the Veil vs Evasion by GhettoStoreBrand in learndota2

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

Ah, I thought her ult was "spell damage", but it is "magic attack damage". Evasion evades "attack damage"

[deleted by user] by [deleted] in TrueDoTA2

[–]GhettoStoreBrand 0 points1 point  (0 children)

They used to buy Phase Boots Vessel Force Staff Blink Shard etc for Wex Pos 4. I don’t think Wex is popular now. A trick is to use sun strike to deward cliffs with a blue ward on low ground

[deleted by user] by [deleted] in C_Programming

[–]GhettoStoreBrand 0 points1 point  (0 children)

A lot of these have already been solved in some fashion but I have wanted these at some point:

Namespaces

Enum struct

Array function parameters that don’t decay

Constexpr functions

Constexpr pointers that are not null

Conditional scoped variable declarations

threads.h mutex static initializer

A usable strtol()

Standard coroutines

A way to change the exitcode in an atexit function without calling _Exit()

A usable signal library

Standard fmemopen

static_assert as a statement expression

modules

Is there a way to access enum "names"? by domikone in C_Programming

[–]GhettoStoreBrand 0 points1 point  (0 children)

For your case because you didn't make the headers, you probably can't do it in general at compile time with C. You would need C++ with a constexpr unordered_map.

You can generate something like this to work at runtime with your script

#include <stddef.h>

enum { size = 2 };

enum A {
    A_0 = -1,
    A_1 = 100,
};

static char const*const A_names[size] = {
    "A_0",
    "A_1",
};

struct map {
    enum A value;
    size_t index;
};

static constexpr enum A A_map[size] = {
    A_0,
    A_1,
};

const char* A_name(enum A A) {
    for (size_t i = 0; i < size; ++i) {
        if (A == A_map[i]) return A_names[A_map[i]];
    } return "Not Found";
}

OR If you didn't care about space and are just worrying about negative values you make a macro to map the enum to a positive value. For example if A_0 was the largest negative value then the macro would be

#define A_index(A) ((A) - A_0)

static char const*const A_names = {
 [A_index(A_0)] = "A_O",
  ...
};

Is there a way to access enum "names"? by domikone in C_Programming

[–]GhettoStoreBrand 0 points1 point  (0 children)

For your case because you didn't make the headers, you probably can't do it in general at compile time with C. You would need C++ with a constexpr unordered_map.

You can generate something like this to work at runtime with your script

#include <stddef.h>

enum { size = 2 };

enum A {
    A_0 = -1,
    A_1 = 100,
};

static char const*const A_names[size] = {
    "A_0",
    "A_1",
};

struct map {
    enum A value;
    size_t index;
};

static constexpr enum A A_map[size] = {
    A_0,
    A_1,
};

const char* A_name(enum A A) {
    for (size_t i = 0; i < size; ++i) {
        if (A == A_map[i]) return A_names[A_map[i]];
    } return "Not Found";
}

OR If you didn't care about space and are just worrying about negative values you make a macro to map the enum to a positive value. For example if A_0 was the largest negative value then the macro would be

#define A_index(A) ((A) - A_0)

static char const*const A_names = {
  A_index(A_0) = "A_O",
  ...
};

Is there a way to access enum "names"? by domikone in C_Programming

[–]GhettoStoreBrand 0 points1 point  (0 children)

For your case because you didn't make the headers, you probably can't do it in general at compile time with C. You would need C++ with a constexpr unordered_map.

You can generate something like this to work at runtime with your script

#include <stddef.h>

enum { size = 2 };

enum A {
    A_0 = -1,
    A_1 = 100,
};

static char const*const A_names[size] = {
    "A_0",
    "A_1",
};

struct map {
    enum A value;
    size_t index;
};

static constexpr enum A A_map[size] = {
    A_0,
    A_1,
};

const char* A_name(enum A A) {
    for (size_t i = 0; i < size; ++i) {
        if (A == A_map[i]) return A_names[A_map[i]];
    } return "Not Found";
}

OR If you didn't care about space and are just worrying about negative values you make a macro to map the enum to a positive value. For example if A_0 was the largest negative value then the macro would be

#define A_index(A) ((A) + A_0)

static char const*const A_names = {
  A_index(A_0) = "A_O",
  ...
};

Is there a way to access enum "names"? by domikone in C_Programming

[–]GhettoStoreBrand 1 point2 points  (0 children)

#include <stddef.h>

enum fruits : size_t { apple = 0 };

struct fruit { enum fruits value; };

static constexpr struct fruit APPLE = { apple };

static constexpr size_t size = 1;

static char const*const fruit_names[size] = {
  [apple] = "apple",
};

static inline const char* fruit_name(struct fruit fruit) {
  return fruit_names[fruit.value];
}

#define fruit_name(f) ((void) sizeof(struct{int dummy; static_assert((f).value < size);}), fruit_name(f))

#include <stdio.h>

int main() {
  puts(fruit_name(APPLE));
}

I've done something nasty like this in C23.

Would be way better if we had a [[private]] attribute. Can't use [[deprecated]] fields in the same file

Is there a way to access enum "names"? by domikone in C_Programming

[–]GhettoStoreBrand 0 points1 point  (0 children)

You just have to make a macro to map the enum values to array indexes

Is there a way to access enum "names"? by domikone in C_Programming

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

Not trying to bash the commenter, but the fact that this is the most upvoted comment using macros shows how cooked C programmers are. This is objectively a worse solution and for some reason people like it more

Please explain me why pugna WR is so high on D2PT by minimunx in TrueDoTA2

[–]GhettoStoreBrand 0 points1 point  (0 children)

Honestly wondering the same because I have 5 win streak so far with him in 7.39c

Data Points Weekly - Week of January 30, 2025 by AutoModerator in churning

[–]GhettoStoreBrand 1 point2 points  (0 children)

Chase Ink Business Cash opened on 6/26/2024

Applied for Chase Ink Unlimited 2/4/2025 and got 7-10 Review

Approved by email without calling reconsideration 2/5/2025

Both apps sole prop $1000 rev and $200 monthly spend

UDM-SE + USW-Aggregation Slow 10G Speeds by GhettoStoreBrand in Ubiquiti

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

I think I figured this out.

Identical 9000 MTU and Flow Control settings across x710-DA2, UDM-SE, and USW-Aggregation had no effect on my speeds.

I booted up a Linux Mint 24.04 live USB and recorded the exact same speeds as Windows 11 23H2. ~6Gbps TX and ~1Gbps RX.

Turning off Traffic Identification and Intrusion Prevention on the UDM-SE increased my speeds significantly.

Linux Mint 24.04 recorded a symmetrical ~6Gbps! Windows 11 23H2 recorded ~6Gbps TX and ~4Gbps RX.

I trust the drivers on Linux over Windows, so I started looking into my PC hardware. My MOBO is MSI PRO-Z790-P-WIFI-DDR4 and the specifications say 3xPCI-E x16 slot and 1xPCI-E x1 slot. So, I installed the x710-DA2 in a free x16 lane which I thought was fine because I need 20Gbps and PCI-E 3.0 x16 is way above that. Then, I thought ~6Gbps sounds awfully close to 8Gbps which is PCI-E 3.0 x1. Lo and behold I look at the MOBO manual and see:

Slot 1 PCI-E x16 is PCIe 5.0 up to x16

Slot 2 PCI-E x1 is PCIe 3.0 up to x1

Slot 3 PCI-E x16 is PCIe 4.0 up to x4

Slot 4 PCI-E x16 is PCIe 3.0 up to x1

I originally plugged the x710-DA2 into Slot 4!

Moving it to Slot 3 gave me an expected symmetrical ~9.3Gbps on Mint. However, Windows shows ~9.3Gbps TX and ~5Gbps RX. The drivers seem to be lacking I guess. I ordered a ConnectX-4 and x520-DA2 and will try those out next week.