diff --git a/libuavcan/include/uavcan/marshal/array.hpp b/libuavcan/include/uavcan/marshal/array.hpp index 44346c4552..d80e1544b3 100644 --- a/libuavcan/include/uavcan/marshal/array.hpp +++ b/libuavcan/include/uavcan/marshal/array.hpp @@ -503,7 +503,8 @@ public: const SizeType max_size = capacity() - size(); // We have one extra byte for the null terminator, hence +1 - const int ret = std::snprintf(reinterpret_cast(ptr), max_size + 1, format, value); + using namespace std; // For snprintf() + const int ret = snprintf(reinterpret_cast(ptr), max_size + 1, format, value); for (int i = 0; i < std::min(ret, int(max_size)); i++) { diff --git a/libuavcan/include/uavcan/time.hpp b/libuavcan/include/uavcan/time.hpp index 9b7c1af440..41bdf451d3 100644 --- a/libuavcan/include/uavcan/time.hpp +++ b/libuavcan/include/uavcan/time.hpp @@ -204,7 +204,8 @@ template inline Stream& operator<<(Stream& s, DurationBase d) { char buf[8]; - std::snprintf(buf, sizeof(buf), "%06lu", static_cast(std::abs(d.toUSec() % 1000000L))); + using namespace std; // For snprintf() + snprintf(buf, sizeof(buf), "%06lu", static_cast(std::abs(d.toUSec() % 1000000L))); if (d.isNegative()) { s << '-'; @@ -217,7 +218,8 @@ template inline Stream& operator<<(Stream& s, TimeBase t) { char buf[8]; - std::snprintf(buf, sizeof(buf), "%06lu", static_cast(t.toUSec() % 1000000L)); + using namespace std; // For snprintf() + snprintf(buf, sizeof(buf), "%06lu", static_cast(t.toUSec() % 1000000L)); s << (t.toUSec() / 1000000L) << '.' << buf; return s; } diff --git a/libuavcan/src/driver/uc_can.cpp b/libuavcan/src/driver/uc_can.cpp index 75d97c2cc3..f85bd3d302 100644 --- a/libuavcan/src/driver/uc_can.cpp +++ b/libuavcan/src/driver/uc_can.cpp @@ -59,7 +59,7 @@ bool CanFrame::priorityHigherThan(const CanFrame& rhs) const std::string CanFrame::toString(StringRepresentation mode) const { - using std::snprintf; + using namespace std; // For snprintf() assert(mode == StrTight || mode == StrAligned); diff --git a/libuavcan/src/transport/uc_frame.cpp b/libuavcan/src/transport/uc_frame.cpp index 8299aad946..fb30cbe963 100644 --- a/libuavcan/src/transport/uc_frame.cpp +++ b/libuavcan/src/transport/uc_frame.cpp @@ -197,6 +197,7 @@ bool Frame::operator==(const Frame& rhs) const std::string Frame::toString() const { + using namespace std; // For snprintf() /* * Frame ID fields, according to UAVCAN specs: * - Data Type ID @@ -208,19 +209,19 @@ std::string Frame::toString() const */ static const int BUFLEN = 100; char buf[BUFLEN]; - int ofs = std::snprintf(buf, BUFLEN, "dtid=%i tt=%i snid=%i dnid=%i idx=%i last=%i tid=%i payload=[", - int(data_type_id_.get()), int(transfer_type_), int(src_node_id_.get()), - int(dst_node_id_.get()), int(frame_index_), int(last_frame_), int(transfer_id_.get())); + int ofs = snprintf(buf, BUFLEN, "dtid=%i tt=%i snid=%i dnid=%i idx=%i last=%i tid=%i payload=[", + int(data_type_id_.get()), int(transfer_type_), int(src_node_id_.get()), + int(dst_node_id_.get()), int(frame_index_), int(last_frame_), int(transfer_id_.get())); for (int i = 0; i < payload_len_; i++) { - ofs += std::snprintf(buf + ofs, BUFLEN - ofs, "%02x", payload_[i]); + ofs += snprintf(buf + ofs, BUFLEN - ofs, "%02x", payload_[i]); if ((i + 1) < payload_len_) { - ofs += std::snprintf(buf + ofs, BUFLEN - ofs, " "); + ofs += snprintf(buf + ofs, BUFLEN - ofs, " "); } } - ofs += std::snprintf(buf + ofs, BUFLEN - ofs, "]"); + ofs += snprintf(buf + ofs, BUFLEN - ofs, "]"); return std::string(buf); } diff --git a/libuavcan/src/transport/uc_transfer_buffer.cpp b/libuavcan/src/transport/uc_transfer_buffer.cpp index b3ce1d8161..276aa70274 100644 --- a/libuavcan/src/transport/uc_transfer_buffer.cpp +++ b/libuavcan/src/transport/uc_transfer_buffer.cpp @@ -15,8 +15,9 @@ namespace uavcan */ std::string TransferBufferManagerKey::toString() const { + using namespace std; // For snprintf() char buf[24]; - std::snprintf(buf, sizeof(buf), "nid=%i tt=%i", int(node_id_.get()), int(transfer_type_)); + snprintf(buf, sizeof(buf), "nid=%i tt=%i", int(node_id_.get()), int(transfer_type_)); return std::string(buf); }