top of page
Using Tools Properly (Analyzing Performance with LLVM Intermediates)
I was looking at some code using a macro to read a uint32_t from a buffer received from a remote device. It looked something like this, give or take a few casts: #define rd_uint32( p ) ( p[0] | ( p[1] << 8 ) | ( p[2] << 16 ) | ( p[3] << 24 ) ) uint32_t n = rd_uint32( buffer ); At first I didn’t realize why the author overcomplicated this, as they could’ve just written something like below: uint32_t n = *( (uint32_t *) buffer ); It took me a while to realize they were writing.
Kiranbir Sodhia
Apr 18, 20132 min read
bottom of page