diff --git a/cmake/win32_compiler_options.cmake b/cmake/win32_compiler_options.cmake index 95049b8411..d86271a8c7 100644 --- a/cmake/win32_compiler_options.cmake +++ b/cmake/win32_compiler_options.cmake @@ -26,11 +26,12 @@ if (MSVC) # numerous warnings when compiling in MSVC. We will ignore them for # now. add_definitions("/wd4290") - add_definitions("/wd4800") + add_definitions("/wd4800") - # Windows still warns about nameless struct/union, but we assume - # that all of our compilers support this - #add_definitions("/wd4201") + # Windows warns about integer narrowing like crazy and it's annoying. + # In most cases the programmer knows what they're doing. A good + # static analysis tool would be better than turning this warning off. + add_definitions("/wd4267") endif() if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]") diff --git a/include/pdal/util/Charbuf.hpp b/include/pdal/util/Charbuf.hpp index 3ce679e410..21b9348180 100644 --- a/include/pdal/util/Charbuf.hpp +++ b/include/pdal/util/Charbuf.hpp @@ -46,13 +46,13 @@ namespace pdal /** Allow a data buffer to be used at a std::streambuf. */ -class PDAL_DLL Charbuf : public std::streambuf +class Charbuf : public std::streambuf { public: /** Construct an empty Charbuf. */ - Charbuf() : m_bufOffset(0) + PDAL_DLL Charbuf() : m_bufOffset(0) {} /** @@ -61,7 +61,7 @@ class PDAL_DLL Charbuf : public std::streambuf \param v Byte vector to back streambuf. \param bufOffset Offset in vector (ignore bytes before offset). */ - Charbuf (std::vector& v, pos_type bufOffset = 0) + PDAL_DLL Charbuf (std::vector& v, pos_type bufOffset = 0) { initialize(v.data(), v.size(), bufOffset); } /** @@ -71,7 +71,7 @@ class PDAL_DLL Charbuf : public std::streambuf \param count Size of buffer. \param bufOffset Offset in vector (ignore bytes before offset). */ - Charbuf (char *buf, size_t count, pos_type bufOffset = 0) + PDAL_DLL Charbuf (char *buf, size_t count, pos_type bufOffset = 0) { initialize(buf, count, bufOffset); } /** @@ -81,7 +81,7 @@ class PDAL_DLL Charbuf : public std::streambuf \param count Size of buffer. \param bufOffset Offset in vector (ignore bytes before offset). */ - void initialize(char *buf, size_t count, pos_type bufOffset = 0); + PDAL_DLL void initialize(char *buf, size_t count, pos_type bufOffset = 0); protected: /** diff --git a/include/pdal/util/OStream.hpp b/include/pdal/util/OStream.hpp index ebc64aaa79..9b2fc3b2c6 100644 --- a/include/pdal/util/OStream.hpp +++ b/include/pdal/util/OStream.hpp @@ -46,19 +46,20 @@ namespace pdal { -class PDAL_DLL OStream +class OStream { public: - OStream() : m_stream(NULL), m_fstream(NULL) + PDAL_DLL OStream() : m_stream(NULL), m_fstream(NULL) {} - OStream(const std::string& filename) : m_stream(NULL), m_fstream(NULL) + PDAL_DLL OStream(const std::string& filename) : + m_stream(NULL), m_fstream(NULL) { open(filename); } - OStream(std::ostream *stream) : m_stream(stream), m_fstream(NULL) + PDAL_DLL OStream(std::ostream *stream) : m_stream(stream), m_fstream(NULL) {} - ~OStream() + PDAL_DLL ~OStream() { delete m_fstream; } - int open(const std::string& filename) + PDAL_DLL int open(const std::string& filename) { if (m_stream) return -1; @@ -66,41 +67,41 @@ class PDAL_DLL OStream std::ios_base::out | std::ios_base::binary); return 0; } - void close() + PDAL_DLL void close() { flush(); delete m_fstream; m_fstream = NULL; m_stream = NULL; } - bool isOpen() const + PDAL_DLL bool isOpen() const { return (bool)m_stream; } - void flush() + PDAL_DLL void flush() { m_stream->flush(); } - operator bool () + PDAL_DLL operator bool () { return (bool)(*m_stream); } - void seek(std::streampos pos) + PDAL_DLL void seek(std::streampos pos) { m_stream->seekp(pos, std::ostream::beg); } - void put(const std::string& s) + PDAL_DLL void put(const std::string& s) { put(s, s.size()); } - void put(const std::string& s, size_t len) + PDAL_DLL void put(const std::string& s, size_t len) { std::string os = s; os.resize(len); m_stream->write(os.c_str(), len); } - void put(const char *c, size_t len) + PDAL_DLL void put(const char *c, size_t len) { m_stream->write(c, len); } - void put(const unsigned char *c, size_t len) + PDAL_DLL void put(const unsigned char *c, size_t len) { m_stream->write((const char *)c, len); } - std::streampos position() const + PDAL_DLL std::streampos position() const { return m_stream->tellp(); } - void pushStream(std::ostream *strm) + PDAL_DLL void pushStream(std::ostream *strm) { m_streams.push(m_stream); m_stream = strm; } - std::ostream *popStream() + PDAL_DLL std::ostream *popStream() { // Can't pop the last stream for now. if (m_streams.empty()) @@ -122,71 +123,71 @@ class PDAL_DLL OStream /// Stream wrapper for output of binary data that converts from host ordering /// to little endian format -class PDAL_DLL OLeStream : public OStream +class OLeStream : public OStream { public: - OLeStream() + PDAL_DLL OLeStream() {} - OLeStream(const std::string& filename) : OStream(filename) + PDAL_DLL OLeStream(const std::string& filename) : OStream(filename) {} - OLeStream(std::ostream *stream) : OStream(stream) + PDAL_DLL OLeStream(std::ostream *stream) : OStream(stream) {} - OLeStream& operator << (uint8_t v) + PDAL_DLL OLeStream& operator << (uint8_t v) { m_stream->put((char)v); return *this; } - OLeStream& operator << (int8_t v) + PDAL_DLL OLeStream& operator << (int8_t v) { m_stream->put((char)v); return *this; } - OLeStream& operator << (uint16_t v) + PDAL_DLL OLeStream& operator << (uint16_t v) { v = htole16(v); m_stream->write((char *)&v, sizeof(v)); return *this; } - OLeStream& operator << (int16_t v) + PDAL_DLL OLeStream& operator << (int16_t v) { v = (int16_t)htole16((uint16_t)v); m_stream->write((char *)&v, sizeof(v)); return *this; } - OLeStream& operator << (uint32_t v) + PDAL_DLL OLeStream& operator << (uint32_t v) { v = htole32(v); m_stream->write((char *)&v, sizeof(v)); return *this; } - OLeStream& operator << (int32_t v) + PDAL_DLL OLeStream& operator << (int32_t v) { v = (int32_t)htole32((uint32_t)v); m_stream->write((char *)&v, sizeof(v)); return *this; } - OLeStream& operator << (uint64_t v) + PDAL_DLL OLeStream& operator << (uint64_t v) { v = htole64(v); m_stream->write((char *)&v, sizeof(v)); return *this; } - OLeStream& operator << (int64_t v) + PDAL_DLL OLeStream& operator << (int64_t v) { v = (int64_t)htole64((uint64_t)v); m_stream->write((char *)&v, sizeof(v)); return *this; } - OLeStream& operator << (float v) + PDAL_DLL OLeStream& operator << (float v) { uint32_t tmp(0); std::memcpy(&tmp, &v, sizeof(v)); @@ -195,7 +196,7 @@ class PDAL_DLL OLeStream : public OStream return *this; } - OLeStream& operator << (double v) + PDAL_DLL OLeStream& operator << (double v) { uint64_t tmp(0); std::memcpy(&tmp, &v, sizeof(v)); @@ -209,7 +210,7 @@ class PDAL_DLL OLeStream : public OStream class OStreamMarker { public: - OStreamMarker(OStream& stream) : m_stream(stream) + PDAL_DLL OStreamMarker(OStream& stream) : m_stream(stream) { if (m_stream.isOpen()) m_pos = m_stream.position(); @@ -217,9 +218,9 @@ class OStreamMarker m_pos = 0; } - void mark() + PDAL_DLL void mark() { m_pos = m_stream.position(); } - void rewind() + PDAL_DLL void rewind() { m_stream.seek(m_pos); } private: diff --git a/io/bpf/BpfCompressor.cpp b/io/bpf/BpfCompressor.cpp index a7ad2265f8..df2eadd608 100644 --- a/io/bpf/BpfCompressor.cpp +++ b/io/bpf/BpfCompressor.cpp @@ -69,7 +69,7 @@ void BpfCompressor::startBlock() void BpfCompressor::compress() { // Note our position so that we know how much we've written. - std::size_t rawWritten = m_out.position(); + uint32_t rawWritten = (uint32_t)m_out.position(); // Pop our temp stream so that we can write the real output file. m_out.popStream(); diff --git a/io/bpf/BpfReader.cpp b/io/bpf/BpfReader.cpp index a117ed0c31..db413b6833 100644 --- a/io/bpf/BpfReader.cpp +++ b/io/bpf/BpfReader.cpp @@ -575,7 +575,8 @@ void BpfReader::seekByteMajor(size_t dimIdx, size_t byteIdx, PointId ptIdx) } -int BpfReader::inflate(char *buf, size_t insize, char *outbuf, size_t outsize) +int BpfReader::inflate(char *buf, uint32_t insize, + char *outbuf, uint32_t outsize) { if (insize == 0) return 0; diff --git a/io/bpf/BpfReader.hpp b/io/bpf/BpfReader.hpp index d64dc838e0..50c5725ef2 100644 --- a/io/bpf/BpfReader.hpp +++ b/io/bpf/BpfReader.hpp @@ -105,7 +105,7 @@ class PDAL_DLL BpfReader : public Reader size_t readBlock(std::vector& outBuf, size_t index); bool eof(); - int inflate(char *inbuf, size_t insize, char *outbuf, size_t outsize); + int inflate(char *inbuf, uint32_t insize, char *outbuf, uint32_t outsize); void seekPointMajor(PointId ptIdx); void seekDimMajor(size_t dimIdx, PointId ptIdx); diff --git a/io/text/TextReader.hpp b/io/text/TextReader.hpp index e7c1db69f4..5b18cfe780 100644 --- a/io/text/TextReader.hpp +++ b/io/text/TextReader.hpp @@ -85,7 +85,7 @@ class PDAL_DLL TextReader : public Reader \param numPts Maximum number of points to read. \return Number of points read. */ - virtual point_count_t read(const PointViewPtr view, point_count_t numPts); + virtual point_count_t read(PointViewPtr view, point_count_t numPts); /** Close input file.