Using reinterpret_cast like that is possibly UB. Replace them with structs/memcpy calls where applicable.