norden.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
Moin! Dies ist die Mastodon-Instanz für Nordlichter, Schnacker und alles dazwischen. Folge dem Leuchtturm.

Administered by:

Server stats:

3.4K
active users

#pointers

0 posts0 participants0 posts today

I would claim that I'm *very* experienced with #programming in #C. But still, C gets annoyingly weird when it comes to #pointers *to* #arrays.

Does the following code look sober to you? 🤔 (My compiler doesn't complain)

Especially interested in the highlighted line, but also the block above trying to expand the array ...

Context: I started work on a generic/configurable rate-limiter to add to #swad.

I would claim that I'm *very* experienced with #programming in #C. But still, C get's annoyingly weird when it comes to #pointers *to* #arrays.

Does the following code look sober to you? 🤔 (My compiler doesn't complain)

Especially interested in the highlighted line, but also the block above trying to expand the array ...

Context: I started work on a generic/configurable rate-limiter to add to #swad.

TIL: C array subscript operators are handled in such a way that `letters[i]` is equivalent to `*(letters + i)` and because addition is commutative, that expression is identical to `*(i + letters)`, which means that `i[letters]` is the same as `letters[i]`.

```
#include <stdio.h>
#include <stddef.h>

int main() {
char letters[3] = "abc";
size_t i = 2;
printf("letters: %p\n", (void *)&letters);
printf("i[letters] (%p): %c\n", (void*)&(i[letters]), i[letters]);
printf("letters[i] (%p): %c\n", (void*)&(letters[i]), letters[i]);
return 0;
}
```

Which outputs:
```
letters: 0x7ffc68ec7bb9
i[letters] (0x7ffc68ec7bbb): c
letters[i] (0x7ffc68ec7bbb): c
```

Mind blown... :neofox_floof_explode:
#til #clang #pointers #programming

I'm unraveling an Unreal Engine editor crash bug.

When the crash happened, the editor got confused internally between 2 characters. One has a set of pointers that the other does not.

When the game starts, and it's time to head to work, a vendor instead sprints to (0,0,0), and the log says one of those pointers is missing. It is not. It is missing in the other character because they are of 2 different base classes, and it doesn't have those pointers. That character with the "missing" pointer was once spawned in the game, but not as a vendor. What they have in common is the same skeletal meshes and animation blueprints.

Somewhere, somehow, it thinks both skeletal meshes use the vendor base class. Uh... no.

I saw the confusion when I was deleting the location markers. It showed both characters were using the location marker that it can't find when the game is running. Uh... no again.

About to delete the character it's confused about. Not the vendor. Yet. I may delete both of them and start over. If this breaks it all, well, thank goodness for backups.

#GameDev#UE5#RPG