Skip to content

Commit

Permalink
Fix warning C4239: nonstandard extension used: 'argument': conversion…
Browse files Browse the repository at this point in the history
… from 'slog::detail::`anonymous-namespace'::log<`anonymous-namespace'::dull_gate,-2147483647>' to 'slog::log_statement &'

message : A non-const reference may only be bound to an lvalue
  • Loading branch information
garethsb committed Nov 22, 2024
1 parent f549712 commit 8c9df91
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions Development/cmake/NmosCppTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(NMOS_CPP_TEST_NMOS_TEST_SOURCES
nmos/test/query_api_test.cpp
nmos/test/sdp_test_utils.cpp
nmos/test/sdp_utils_test.cpp
nmos/test/slog_test.cpp
nmos/test/system_resources_test.cpp
nmos/test/video_jxsv_test.cpp
)
Expand Down
8 changes: 8 additions & 0 deletions Development/nmos/slog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ namespace slog
{
return s << utility::conversions::to_utf8string(u16s);
}
inline log_statement& operator<<(log_statement&& s, const utf16string& u16s)
{
return s << u16s;
}
}

namespace nmos
Expand All @@ -25,6 +29,10 @@ namespace nmos
{
return s << id_type.second.name << ": " << id_type.first;
}
inline slog::log_statement& operator<<(slog::log_statement&& s, const std::pair<nmos::id, nmos::type>& id_type)
{
return s << id_type;
}

// Log message categories
typedef std::string category;
Expand Down
26 changes: 26 additions & 0 deletions Development/nmos/test/slog_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// The first "test" is of course whether the header compiles standalone
#include "nmos/slog.h"

#include "bst/test/test.h"

namespace
{
struct dull_gate
{
bool pertinent(slog::severity level) const { return true; }
void log(const slog::log_message& message) {}
};
}

BST_TEST_CASE(testSlogLog)
{
dull_gate gate;
const auto str = utility::string_t{ U("foo") };
const auto it = std::make_pair(nmos::id{ U("bar") }, nmos::types::node);
// log statement
slog::log<SLOG_LOGGING_SEVERITY>(gate, SLOG_FLF) << str << 42 << str;
slog::log<SLOG_LOGGING_SEVERITY>(gate, SLOG_FLF) << it << 42 << it;
// no log statement
slog::log<SLOG_LOGGING_SEVERITY - 1>(gate, SLOG_FLF) << str << 42 << str;
slog::log<SLOG_LOGGING_SEVERITY - 1>(gate, SLOG_FLF) << it << 42 << it;
}

0 comments on commit 8c9df91

Please sign in to comment.