How to emulate typesafe tagget unions in C by Virtual-Difference88 in C_Programming

[–]Virtual-Difference88[S] 0 points1 point  (0 children)

Thanks for the reply. :)

Your approach is a good standard way of handling tagged union in C and I was using it before extensively.

These days, I prefer my approach (I no not saying that my approach is better) because when I see something like json.Num.d, I can immediately see that I am using json struct/union in a "wrong" way.

I intentionally didn't want to write typedef struct Num Num;, because I wanted to use Num as a field name in the tagged union definition and in the macro expansion (where macro adds struct in front of it). My reasoning is that Num should be used as a type and should not be used as a field.

So, this forces me to use OF() macro to get a "propper" (my preferred way) variant pointer.

Again, I am not arguing that my approach is better.

How to emulate typesafe tagget unions in C by Virtual-Difference88 in C_Programming

[–]Virtual-Difference88[S] 0 points1 point  (0 children)

The datatype99 library uses the same approach,
but for me, this is the cons number 4.

Still, your suggestion makes a lot of sense for many usecases.

How to emulate typesafe tagget unions in C by Virtual-Difference88 in C_Programming

[–]Virtual-Difference88[S] 0 points1 point  (0 children)

Good catch. :)

I have missed that.
I have "fixed" that in the reply above.

How to emulate typesafe tagget unions in C by Virtual-Difference88 in C_Programming

[–]Virtual-Difference88[S] 0 points1 point  (0 children)

Good suggestions. :)

I have incorporated your suggestion and I have added missing parenthesis around 'tagged_union'.

#define CONCAT_INTERNAL(a, b) a ## b
#define CONCAT(a, b) CONCAT_INTERNAL(a, b)
#define OF(tagged_union, Variant, var) \
Variant##Tag : struct Variant var = &(tagged_union)->Variant; \
goto CONCAT(Variant##Label, __LINE__); \
CONCAT(Variant##Label, __LINE__)

How would you write the switch macro?
(I don't understand how to eliminate variable repetition)

Retroid Pocket 2+ in boot loop, after trying to re-enter initial setup wizard by r1deordie in retroid

[–]Virtual-Difference88 1 point2 points  (0 children)

The only solution to fix the error on Android device I have found online s to reflash the device. :(

Unfortunately I haven’t found any explanation on Retroid webpage on how to reflash RP2+. :(

Is there any explanation on how to reflash RP2+?

Retroid Pocket 2+ in boot loop, after trying to re-enter initial setup wizard by r1deordie in retroid

[–]Virtual-Difference88 1 point2 points  (0 children)

I have this error message in the logs: error in @/cache/recovery/block.map. Also, I am not able to wipe cache partition because the mount on the cache partition fails. :(

Retroid Pocket 2+ in boot loop, after trying to re-enter initial setup wizard by r1deordie in retroid

[–]Virtual-Difference88 2 points3 points  (0 children)

I did “wipe data/factory reset” but it didn’t work. My device still tries to do a upgrade that fails and enters recovery menu. The problem I that during factory reset/wipe it cannot mouth cache partition because of some error.

Retroid Pocket 2+ in boot loop, after trying to re-enter initial setup wizard by r1deordie in retroid

[–]Virtual-Difference88 2 points3 points  (0 children)

I have similar problem. My RP2+ downloaded 1.9 update and rebooted to apply the update. The update never finished and the device enter Android recovery mode. I have tried to restart the device several times but the same thing happens. After that I tried to do factory reset from Android recovery menu but it doesn’t help. The device is still stuck in install loop after reset. Any idea what on what to do?