From c4b9bb2c01b2bb7e1db4dad67b1d4969dd600299 Mon Sep 17 00:00:00 2001 From: kingscallop <54776947+kingscallop@users.noreply.github.com> Date: Sun, 1 May 2022 20:11:43 +0100 Subject: [PATCH] Fix ambiguous overloaded call on SPK::IO::Buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When trying to write a 'size_t' to a SPK::IO::Buffer, the following error happens. spark/include/Core/IO/SPK_IO_Buffer.h:224:27: error: call of overloaded ‘put(long unsigned int&)’ is ambiguous 224 | buffer.put(value); | ~~~~~~~~~~^~~~~~~ spark/include/Core/IO/SPK_IO_Buffer.h:76:22: note: candidate: ‘void SPK::IO::Buffer::put(char)’ 76 | void put(char c); | ^~~ spark/include/Core/IO/SPK_IO_Buffer.h:96:22: note: candidate: ‘void SPK::IO::Buffer::put(unsigned char)’ 96 | void put(unsigned char c) { put((char)c); } | ^~~ spark/include/Core/IO/SPK_IO_Buffer.h:97:22: note: candidate: ‘void SPK::IO::Buffer::put(signed char)’ 97 | void put(signed char c) { put((char)c); } etc. As there is no overload to 'size_t', the patch casts it to unsigned int. --- src/Extensions/IOConverters/SPK_IO_SPKSaver.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Extensions/IOConverters/SPK_IO_SPKSaver.cpp b/src/Extensions/IOConverters/SPK_IO_SPKSaver.cpp index c23d7b4e..efffc446 100644 --- a/src/Extensions/IOConverters/SPK_IO_SPKSaver.cpp +++ b/src/Extensions/IOConverters/SPK_IO_SPKSaver.cpp @@ -108,7 +108,7 @@ namespace IO template void storeValue(const std::vector >& value, Buffer& buffer) { - buffer << value.size(); + buffer << static_cast(value.size()); for(unsigned int t = 0; t < value.size(); t++) buffer << saver->context->refId(value[t].get()); } @@ -142,7 +142,7 @@ namespace IO unsigned int pos = buffer.getPosition(); buffer.setPosition(nbAttrPos); buffer << nbAttrs; - buffer << (pos - buffer.getPosition() - 4); + buffer << (pos - static_cast(buffer.getPosition()) - 4); buffer.setPosition(pos); } @@ -236,7 +236,7 @@ namespace IO // Header context->buffer << SPKFormatVariables::MAGIC_NUMBER << SPKFormatVariables::VERSION - << objRef.size(); + << static_cast(objRef.size()); context->nbConnectionPosition = context->buffer.getPosition(); context->buffer << (unsigned int)0; // Number of connections will be known in the 2nd phase context->buffer << (unsigned int)0; // Data-length is not already known @@ -273,7 +273,7 @@ namespace IO context->buffer.setPosition(context->nbConnectionPosition); context->buffer << context->nbConnections; - context->buffer << (context->buffer.getSize() - context->buffer.getPosition() - 4); + context->buffer << static_cast(context->buffer.getSize() - context->buffer.getPosition() - 4); context->os.write(context->buffer.getData(), context->buffer.getSize()); SPK_DELETE(context);