#include "endian.hpp" #include #include #include using namespace std; using namespace boost; using namespace boost::interface; void Print(const void* p) { const unsigned char* cp = reinterpret_cast(p); for (int i=0; i != 4; ++i) cout << ' ' << unsigned(cp[i]); } // << ptr struct Msg { endian lil_x; endian big_x; }; // Msg Msg msg; volatile uint32_t lil_result; volatile uint32_t big_result; void PrintResults() { cout << hex; cout << msg.lil_x; Print(&msg.lil_x); cout << endl; cout << msg.big_x; Print(&msg.big_x); cout << endl; } int main() { msg.lil_x = 0x12345678; lil_result = msg.lil_x; msg.big_x = 0x87654321; big_result = msg.big_x; PrintResults(); } // main