Skip to content

Fixes to compile in vc14 #25

@guruofquality

Description

@guruofquality

With the recent logger fix I was able to build umtrx again, but I needed a few more changes:

  • umtrx_eeprom.cpp missing an include
  • And an issue in the new logger stuff where the ternary operator and uhd::_log::log constructor looses the reference type and tries to copy the log object. The current macro might be a little bit compiler specific because of that. My solution below was to make a helper function:
diff --git a/host/umtrx_eeprom.cpp b/host/umtrx_eeprom.cpp
index ef6a09d8..083a8fe5 100644
--- a/host/umtrx_eeprom.cpp
+++ b/host/umtrx_eeprom.cpp
@@ -15,6 +15,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
+#include "umtrx_impl.hpp"
 #include <uhd/usrp/mboard_eeprom.hpp>
 #include <uhd/types/mac_addr.hpp>
 #include <uhd/types/byte_vector.hpp>
diff --git a/host/umtrx_log_adapter.hpp b/host/umtrx_log_adapter.hpp
index c41d2754..df091ba6 100644
--- a/host/umtrx_log_adapter.hpp
+++ b/host/umtrx_log_adapter.hpp
@@ -9,15 +9,23 @@
 #else // UHD_HAS_MSG_HPP
 #include <uhd/utils/log.hpp>
 
-enum {
+enum _umtrx_uhd_log_level_t {
     _uhd_log_level_status,
     _uhd_log_level_warning,
     _uhd_log_level_error
 };
 
-#define UHD_MSG(severity) ((_uhd_log_level_##severity==_uhd_log_level_status)?UHD_LOGGER_INFO("UmTRX"): \
-                           (_uhd_log_level_##severity==_uhd_log_level_warning)?UHD_LOGGER_WARNING("UmTRX"): \
-                           UHD_LOGGER_ERROR("UmTRX"))
+static inline uhd::_log::log &_umtrx_get_uhd_logger(const _umtrx_uhd_log_level_t level)
+{
+    switch(level)
+    {
+    case _uhd_log_level_status: return UHD_LOGGER_INFO("UmTRX");
+    case _uhd_log_level_warning: return UHD_LOGGER_WARNING("UmTRX");
+    case _uhd_log_level_error: return UHD_LOGGER_ERROR("UmTRX");
+    }
+}
+
+#define UHD_MSG(severity) (_umtrx_get_uhd_logger(_uhd_log_level_##severity))
 
 #endif // UHD_HAS_MSG_HPP

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions