ddiakopoulos / tinyply

:earth_africa: C++11 ply 3d mesh format importer & exporter
598 stars 118 forks source link

Silencing compilation warnings #29

Open kedestin opened 5 years ago

kedestin commented 5 years ago

Hey, thanks for the the great library.

Compiling the with -Wall -Wextra -Wpedantic -Wshadow shows the following warnings

tinyply/source/tinyply.h:77:29: warning: declaration shadows a field of 'tinyply::Buffer' [-Wshadow]
        Buffer(const size_t size) : data(new uint8_t[size], delete_array()), size(size) { alias = data.get(); } // allocating
                            ^
tinyply/source/tinyply.h:74:16: note: previous declaration is here
        size_t size;
               ^
tinyply/source/tinyply.h:393:78: warning: unused parameter 'is' [-Wunused-parameter]
void PlyFile::PlyFileImpl::read_header_text(std::string line, std::istream & is, std::vector<std::string>& place, int erase)
                                                                             ^
tinyply/source/tinyply.h:417:64: warning: unused parameter 't' [-Wunused-parameter]
size_t PlyFile::PlyFileImpl::read_property_binary(const Type & t, const size_t & stride, void * dest, size_t & destOffset, std::istream & is)
                                                               ^
tinyply/source/tinyply.h:460:55: warning: unused parameter 't' [-Wunused-parameter]
void PlyFile::PlyFileImpl::write_property_binary(Type t, std::ostream & os, uint8_t * src, size_t & srcOffset, const size_t & stride)
                                                      ^
tinyply/source/tinyply.h:473:17: warning: unused variable 'b' [-Wunused-variable]
    for (auto & b : buffers) for (auto & entry : userData) list_hints += entry.second.list_size_hint;
                ^
tinyply/source/tinyply.h:600:39: warning: comparison of integers of different signs: 'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
                    for (int j = 0; j < p.listCount; ++j)
                                    ~ ^ ~~~~~~~~~~~
tinyply/source/tinyply.h:691:101: warning: adding 'uint32_t' (aka 'unsigned int') to a string does not append to the string [-Wstring-plus-int]
                    throw std::invalid_argument("element-property key has already been requested: " + hash_fnv1a(element.name + property.name));
                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tinyply/source/tinyply.h:691:101: note: use array indexing to silence this warning
                    throw std::invalid_argument("element-property key has already been requested: " + hash_fnv1a(element.name + property.name));
                                                                                                    ^
                                                &                                                   [                                         ]
tinyply/source/tinyply.h:767:21: warning: 5 enumeration values not handled in switch: 'INVALID', 'INT8', 'UINT8'... [-Wswitch]
            switch (t)
                    ^

Would it be possible to remedy these?

EgeCiklabakkal commented 5 years ago

Hello,

In my case, these warnings were caused by #include "tinyply.h" line in tinyply.cpp

I wrapped the following onto that line and no longer getting the warnings. I believe this can be used as a temporary solution.

#pragma GCC diagnostic push 
#pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "tinyply.h"
#pragma GCC diagnostic pop