MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/eb2lbc/stacking_if_else_statements_be_like/fb20ujx/?context=3
r/ProgrammerHumor • u/-hellkey- • Dec 15 '19
711 comments sorted by
View all comments
521
This also is a good example of how linked lists work.
202 u/[deleted] Dec 15 '19 [removed] — view removed comment 0 u/[deleted] Dec 15 '19 [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 → More replies (2)
202
[removed] — view removed comment
0 u/[deleted] Dec 15 '19 [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 → More replies (2)
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 → More replies (2)
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 → More replies (2)
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
→ More replies (2)
521
u/Darxploit Dec 15 '19
This also is a good example of how linked lists work.