News for hackers. Stuff that matters.
Re:Using Zig's translate-C to understand weird C code by MauranKilom on Wednesday November 03, 2021 @06:42AM (#29092942)
The only particularly messy part in the C code there is the (int*(*)[]) type cast.

My intuition (because I don't usually have to deal with this kind of nonsense) is "cast to a pointer to an array of int pointers". cdecl confirms that: https://cdecl.org/?q=int*%28*x%29%5B%5D

So we cast a (pointer to pointer to int) to (pointer to array of int pointers) [we can ignore the detour through void*] and then immediately dereference through all three layers. Which gives us back the only int in the program.

Excellent example of how to be a Three Star Programmer I guess: https://wiki.c2.com/?ThreeStarProgrammer

Re:Using Zig's translate-C to understand weird C code by pmarreck on Wednesday November 03, 2021 @12:21PM (#29096793)
TIL about cdecl.org

I don't code in C day to day but this will help for the odd time I need to understand C code!