mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-26 03:52:41 +00:00
Fix Visual Studio 2017 new warning (C4244: 'argument': conversion fro… (#4261)
* Fix Visual Studio 2017 new warning (C4244: 'argument': conversion from 'int' to 'const char', possible loss of data) * Fix Visual Studio 2017 pedantic warnings * Fix Visual Studio 2017 pedantic warnings
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
28e7dbd3d3
commit
e6fa7b1133
@@ -114,6 +114,11 @@ inline uint64_t StringToUInt(const char *str, char **endptr = nullptr,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pedantic warning free version of toupper().
|
||||||
|
inline char ToUpper(char c) {
|
||||||
|
return static_cast<char>(::toupper(c));
|
||||||
|
}
|
||||||
|
|
||||||
typedef bool (*LoadFileFunction)(const char *filename, bool binary,
|
typedef bool (*LoadFileFunction)(const char *filename, bool binary,
|
||||||
std::string *dest);
|
std::string *dest);
|
||||||
typedef bool (*FileExistsFunction)(const char *filename);
|
typedef bool (*FileExistsFunction)(const char *filename);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
guard += *it + "_";
|
guard += *it + "_";
|
||||||
}
|
}
|
||||||
guard += "H_";
|
guard += "H_";
|
||||||
std::transform(guard.begin(), guard.end(), guard.begin(), ::toupper);
|
std::transform(guard.begin(), guard.end(), guard.begin(), ToUpper);
|
||||||
return guard;
|
return guard;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,7 +852,7 @@ class CppGenerator : public BaseGenerator {
|
|||||||
|
|
||||||
std::string GenFieldOffsetName(const FieldDef &field) {
|
std::string GenFieldOffsetName(const FieldDef &field) {
|
||||||
std::string uname = field.name;
|
std::string uname = field.name;
|
||||||
std::transform(uname.begin(), uname.end(), uname.begin(), ::toupper);
|
std::transform(uname.begin(), uname.end(), uname.begin(), ToUpper);
|
||||||
return "VT_" + uname;
|
return "VT_" + uname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ void AccessFlatBufferTest(const uint8_t *flatbuf, size_t length,
|
|||||||
// Test accessing a vector of sorted structs
|
// Test accessing a vector of sorted structs
|
||||||
auto vecofstructs = monster->testarrayofsortedstruct();
|
auto vecofstructs = monster->testarrayofsortedstruct();
|
||||||
if (vecofstructs) { // not filled in monster_test.bfbs
|
if (vecofstructs) { // not filled in monster_test.bfbs
|
||||||
for (size_t i = 0; i < vecofstructs->size()-1; i++) {
|
for (flatbuffers::uoffset_t i = 0; i < vecofstructs->size()-1; i++) {
|
||||||
auto left = vecofstructs->Get(i);
|
auto left = vecofstructs->Get(i);
|
||||||
auto right = vecofstructs->Get(i+1);
|
auto right = vecofstructs->Get(i+1);
|
||||||
TEST_EQ(true, (left->KeyCompareLessThan(right)));
|
TEST_EQ(true, (left->KeyCompareLessThan(right)));
|
||||||
|
|||||||
Reference in New Issue
Block a user