From b33c109889cc01b064f09655c4bed69c179cdf85 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 23 Nov 2010 19:47:36 -0800 Subject: usrp: replace struct member sizeof with this macro so it compiles on mac --- host/lib/usrp/mboard_eeprom.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index a9270cda6..863a80191 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -197,6 +197,9 @@ template static const byte_vector_t to_bytes(const T &item){ ); } +#define sizeof_member(struct_name, member_name) \ + sizeof(reinterpret_cast(NULL)->member_name) + static void load_e100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ const size_t num_bytes = offsetof(e100_eeprom_map, model); byte_vector_t map_bytes = iface.read_eeprom(E100_EEPROM_ADDR, 0, num_bytes); @@ -208,7 +211,7 @@ static void load_e100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ mb_eeprom["content"] = boost::lexical_cast(unsigned(map.content)); #define load_e100_string_xx(key) mb_eeprom[#key] = bytes_to_string(iface.read_eeprom( \ - E100_EEPROM_ADDR, offsetof(e100_eeprom_map, key), sizeof(e100_eeprom_map::key) \ + E100_EEPROM_ADDR, offsetof(e100_eeprom_map, key), sizeof_member(e100_eeprom_map, key) \ )); load_e100_string_xx(model); @@ -242,7 +245,7 @@ static void store_e100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ #define store_e100_string_xx(key) if (mb_eeprom.has_key(#key)) iface.write_eeprom( \ E100_EEPROM_ADDR, offsetof(e100_eeprom_map, key), \ - string_to_bytes(mb_eeprom[#key], sizeof(e100_eeprom_map::key)) \ + string_to_bytes(mb_eeprom[#key], sizeof_member(e100_eeprom_map, key)) \ ); store_e100_string_xx(model); -- cgit v1.2.3