diff options
author | Josh Blum <josh@joshknows.com> | 2010-11-23 19:47:36 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-11-23 19:47:36 -0800 |
commit | b33c109889cc01b064f09655c4bed69c179cdf85 (patch) | |
tree | 1a615f7ddae227b2cccd1ac114e99d04749c665b /host/lib/usrp/mboard_eeprom.cpp | |
parent | adee39f089420ce4cbf3d2da156b4b82c4240313 (diff) | |
download | uhd-b33c109889cc01b064f09655c4bed69c179cdf85.tar.gz uhd-b33c109889cc01b064f09655c4bed69c179cdf85.tar.bz2 uhd-b33c109889cc01b064f09655c4bed69c179cdf85.zip |
usrp: replace struct member sizeof with this macro so it compiles on mac
Diffstat (limited to 'host/lib/usrp/mboard_eeprom.cpp')
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 7 |
1 files 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 <typename T> static const byte_vector_t to_bytes(const T &item){ ); } +#define sizeof_member(struct_name, member_name) \ + sizeof(reinterpret_cast<struct_name*>(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<std::string>(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); |