This is an automated email from the ASF dual-hosted git repository.

isapego pushed a commit to branch ignite-17424
in repository https://gitbox.apache.org/repos/asf/ignite-3.git

commit b26ca7c06fa8f3bed5a66cbf5e2cef3c524fdd0f
Author: Igor Sapego <[email protected]>
AuthorDate: Sun Aug 28 15:46:56 2022 +0400

    IGNITE-17424 Fix compilation for MSVC
---
 .gitignore                                         |  2 +-
 modules/platforms/cpp/CMakeLists.txt               |  2 +-
 modules/platforms/cpp/client-test/CMakeLists.txt   |  3 +-
 modules/platforms/cpp/common/CMakeLists.txt        |  5 +++-
 modules/platforms/cpp/common/Platform.h            | 32 ++++++++++++++++++++++
 .../platforms/cpp/schema/BinaryTupleBuilder.cpp    |  3 +-
 modules/platforms/cpp/schema/BinaryTupleBuilder.h  |  3 +-
 modules/platforms/cpp/schema/BinaryTupleParser.cpp |  6 ++--
 modules/platforms/cpp/schema/BinaryTupleParser.h   |  2 +-
 modules/platforms/cpp/schema/BinaryTupleSchema.h   |  2 +-
 modules/platforms/cpp/schema/DataType.cpp          |  1 +
 11 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index 316612563b..823c84ef00 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,4 +18,4 @@ build/
 *.ipr
 out/
 
-modules/platforms/cpp/cmake-build-*
\ No newline at end of file
+modules/platforms/cpp/cmake-build-*
diff --git a/modules/platforms/cpp/CMakeLists.txt 
b/modules/platforms/cpp/CMakeLists.txt
index c4c3b0e195..fd36bf09ab 100644
--- a/modules/platforms/cpp/CMakeLists.txt
+++ b/modules/platforms/cpp/CMakeLists.txt
@@ -18,7 +18,7 @@
 cmake_minimum_required(VERSION 3.10)
 project(Ignite.C++ VERSION 3 LANGUAGES CXX)
 
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION})
diff --git a/modules/platforms/cpp/client-test/CMakeLists.txt 
b/modules/platforms/cpp/client-test/CMakeLists.txt
index 31c54604a6..33601b2175 100644
--- a/modules/platforms/cpp/client-test/CMakeLists.txt
+++ b/modules/platforms/cpp/client-test/CMakeLists.txt
@@ -22,7 +22,7 @@ set(TARGET ${PROJECT_NAME})
 include_directories(include src)
 
 enable_testing()
-find_package(gtest REQUIRED)
+find_package(GTest REQUIRED)
 include_directories(${GTEST_INCLUDE_DIR})
 
 set(SOURCES
@@ -33,4 +33,5 @@ add_executable(${TARGET} ${SOURCES})
 
 target_link_libraries(${TARGET} ignite-test-common ignite-client 
${GTEST_LIBRARY_DEBUG} ${GTEST_MAIN_LIBRARY_DEBUG})
 
+set(TEST_TARGET IgniteClientTest)
 add_test(NAME ${TEST_TARGET} COMMAND ${TARGET})
diff --git a/modules/platforms/cpp/common/CMakeLists.txt 
b/modules/platforms/cpp/common/CMakeLists.txt
index 661910a7ef..150b4c73a8 100644
--- a/modules/platforms/cpp/common/CMakeLists.txt
+++ b/modules/platforms/cpp/common/CMakeLists.txt
@@ -19,7 +19,10 @@ project(ignite-common)
 
 set(TARGET ${PROJECT_NAME})
 
-set(HEADERS Types.h)
+set(HEADERS
+    Types.h
+    Platform.h
+)
 
 add_library(${TARGET} INTERFACE)
 
diff --git a/modules/platforms/cpp/common/Platform.h 
b/modules/platforms/cpp/common/Platform.h
new file mode 100644
index 0000000000..2901abf986
--- /dev/null
+++ b/modules/platforms/cpp/common/Platform.h
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#define LITTLE_ENDIAN 1
+#define BIG_ENDIAN 2
+
+#ifdef __BYTE_ORDER__
+#   if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#       define BYTE_ORDER LITTLE_ENDIAN
+#   else
+#       define BYTE_ORDER BIG_ENDIAN
+#   endif
+#else
+//TODO: Fix this
+#   define BYTE_ORDER LITTLE_ENDIAN
+#endif
\ No newline at end of file
diff --git a/modules/platforms/cpp/schema/BinaryTupleBuilder.cpp 
b/modules/platforms/cpp/schema/BinaryTupleBuilder.cpp
index ea1b3a8db3..07cf16dde3 100644
--- a/modules/platforms/cpp/schema/BinaryTupleBuilder.cpp
+++ b/modules/platforms/cpp/schema/BinaryTupleBuilder.cpp
@@ -19,6 +19,7 @@
 #include "BinaryTupleParser.h"
 
 #include <stdexcept>
+#include <string>
 
 namespace ignite {
 
@@ -76,7 +77,7 @@ SizeT BinaryTupleBuilder::sizeOf(DATA_TYPE type, BytesView 
bytes) {
             return sizeOfDouble(BinaryTupleParser::getDouble(bytes));
         case DATA_TYPE::STRING:
         case DATA_TYPE::BINARY:
-            return bytes.size();
+            return static_cast<SizeT>(bytes.size());
 
         case DATA_TYPE::UUID:
         case DATA_TYPE::DATE:
diff --git a/modules/platforms/cpp/schema/BinaryTupleBuilder.h 
b/modules/platforms/cpp/schema/BinaryTupleBuilder.h
index 77ea5bb48d..812fc4f954 100644
--- a/modules/platforms/cpp/schema/BinaryTupleBuilder.h
+++ b/modules/platforms/cpp/schema/BinaryTupleBuilder.h
@@ -19,6 +19,7 @@
 
 #include "BinaryTupleSchema.h"
 #include "common/Types.h"
+#include "common/Platform.h"
 
 #include <cassert>
 #include <cstring>
@@ -307,7 +308,7 @@ private:
      * @return Required size.
      */
     static SizeT sizeOfDouble(double value) noexcept {
-        float floatValue = value;
+        float floatValue = static_cast<float>(value);
         return floatValue == value ? sizeOfFloat(floatValue) : sizeof(double);
     }
 
diff --git a/modules/platforms/cpp/schema/BinaryTupleParser.cpp 
b/modules/platforms/cpp/schema/BinaryTupleParser.cpp
index 73767476e6..4ebb75c5d4 100644
--- a/modules/platforms/cpp/schema/BinaryTupleParser.cpp
+++ b/modules/platforms/cpp/schema/BinaryTupleParser.cpp
@@ -16,6 +16,7 @@
  */
 
 #include "BinaryTupleParser.h"
+#include "common/Platform.h"
 
 #include <cassert>
 #include <cstring>
@@ -62,8 +63,9 @@ BinaryTupleParser::BinaryTupleParser(IntT numElements, 
BytesView data)
     static_assert(BYTE_ORDER == LITTLE_ENDIAN);
     memcpy(&offset, nextEntry + tableSize - entrySize, entrySize);
     const std::byte *tupleEnd = valueBase + offset;
-    if (binaryTuple.end() > tupleEnd) {
-        binaryTuple.remove_suffix(binaryTuple.end() - tupleEnd);
+    const std::byte *currentEnd = &(*binaryTuple.end());
+    if (currentEnd > tupleEnd) {
+        binaryTuple.remove_suffix(currentEnd - tupleEnd);
     }
 }
 
diff --git a/modules/platforms/cpp/schema/BinaryTupleParser.h 
b/modules/platforms/cpp/schema/BinaryTupleParser.h
index de949801b4..552e93f6f1 100644
--- a/modules/platforms/cpp/schema/BinaryTupleParser.h
+++ b/modules/platforms/cpp/schema/BinaryTupleParser.h
@@ -70,7 +70,7 @@ public:
      *
      * @return Tuple size.
      */
-    SizeT getSize() const noexcept { return binaryTuple.size(); }
+    SizeT getSize() const noexcept { return 
static_cast<SizeT>(binaryTuple.size()); }
 
     /**
      * @brief Gets the expected total number of tuple elements.
diff --git a/modules/platforms/cpp/schema/BinaryTupleSchema.h 
b/modules/platforms/cpp/schema/BinaryTupleSchema.h
index b2b4bf7a18..624dfd0c3b 100644
--- a/modules/platforms/cpp/schema/BinaryTupleSchema.h
+++ b/modules/platforms/cpp/schema/BinaryTupleSchema.h
@@ -72,7 +72,7 @@ public:
      *
      * @return Number of elements.
      */
-    IntT numElements() const noexcept { return elements.size(); }
+    IntT numElements() const noexcept { return 
static_cast<IntT>(elements.size()); }
 
     /**
      * @brief Gets element info.
diff --git a/modules/platforms/cpp/schema/DataType.cpp 
b/modules/platforms/cpp/schema/DataType.cpp
index 17d15806cd..77b2a6c61a 100644
--- a/modules/platforms/cpp/schema/DataType.cpp
+++ b/modules/platforms/cpp/schema/DataType.cpp
@@ -18,6 +18,7 @@
 #include "DataType.h"
 
 #include <stdexcept>
+#include <string>
 
 namespace ignite {
 

Reply via email to