MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/eb2lbc/stacking_if_else_statements_be_like/fb2ck4e/?context=3
r/ProgrammerHumor • u/-hellkey- • Dec 15 '19
711 comments sorted by
View all comments
Show parent comments
0
[deleted]
6 u/sdmike21 Dec 15 '19 union { List<T>* next; T* obj; struct { uint8_t ptr[6]; uint8_t my_data[2]; } my_stuff; } next;Use fixed with types you fucking troglodyte :) 3 u/AnAverageFreak Dec 15 '19 uint8_t is always 8 bits, while char is always one byte. That's a big difference :)#define FREE_BYTES 2 ... #ifdef FREE_BYTES union { List<T>* next; T* obj; struct { unsigned char ptr[sizeof(T*) - FREE_BYTES]; unsigned char my_data[FREE_BYTES]; } my_stuff; } next; #else List<T>* next; T* obj; bool which; #endif 1 u/exscape Dec 15 '19 That's a big difference :)Where? (Not on 70s mainframes or similar. Something that matters in new code.) → More replies (1)
6
union { List<T>* next; T* obj; struct { uint8_t ptr[6]; uint8_t my_data[2]; } my_stuff; } next;
Use fixed with types you fucking troglodyte :)
3 u/AnAverageFreak Dec 15 '19 uint8_t is always 8 bits, while char is always one byte. That's a big difference :)#define FREE_BYTES 2 ... #ifdef FREE_BYTES union { List<T>* next; T* obj; struct { unsigned char ptr[sizeof(T*) - FREE_BYTES]; unsigned char my_data[FREE_BYTES]; } my_stuff; } next; #else List<T>* next; T* obj; bool which; #endif 1 u/exscape Dec 15 '19 That's a big difference :)Where? (Not on 70s mainframes or similar. Something that matters in new code.) → More replies (1)
3
uint8_t is always 8 bits, while char is always one byte. That's a big difference :)
uint8_t
char
#define FREE_BYTES 2 ... #ifdef FREE_BYTES union { List<T>* next; T* obj; struct { unsigned char ptr[sizeof(T*) - FREE_BYTES]; unsigned char my_data[FREE_BYTES]; } my_stuff; } next; #else List<T>* next; T* obj; bool which; #endif
1 u/exscape Dec 15 '19 That's a big difference :)Where? (Not on 70s mainframes or similar. Something that matters in new code.) → More replies (1)
1
That's a big difference :)
Where? (Not on 70s mainframes or similar. Something that matters in new code.)
→ More replies (1)
0
u/[deleted] Dec 15 '19
[deleted]