diff --git a/AirLib/AirLib.vcxproj b/AirLib/AirLib.vcxproj index be74c4c9d..eb9fb8de2 100644 --- a/AirLib/AirLib.vcxproj +++ b/AirLib/AirLib.vcxproj @@ -197,26 +197,26 @@ StaticLibrary true - v141 + v142 Unicode StaticLibrary false - v141 + v142 true Unicode StaticLibrary true - v141 + v142 Unicode StaticLibrary false - v141 + v142 true Unicode diff --git a/AirLib/include/vehicles/multirotor/firmwares/mavlink/MavLinkMultirotorApi.hpp b/AirLib/include/vehicles/multirotor/firmwares/mavlink/MavLinkMultirotorApi.hpp index a54a9f6b2..74a4d4816 100644 --- a/AirLib/include/vehicles/multirotor/firmwares/mavlink/MavLinkMultirotorApi.hpp +++ b/AirLib/include/vehicles/multirotor/firmwares/mavlink/MavLinkMultirotorApi.hpp @@ -939,7 +939,14 @@ class MavLinkMultirotorApi : public MultirotorApiBase (info.displayName.find(L"PX4_") != std::string::npos) )) { // printf("Auto Selecting COM port: %S\n", info.displayName.c_str()); - return std::string(info.portName.begin(), info.portName.end()); + + std::string portName_str; + + for (wchar_t ch : info.portName) + { + portName_str.push_back(static_cast(ch)); + } + return portName_str; } } return ""; diff --git a/AirLibUnitTests/AirLibUnitTests.vcxproj b/AirLibUnitTests/AirLibUnitTests.vcxproj index 8ee90fce9..f6197fe05 100644 --- a/AirLibUnitTests/AirLibUnitTests.vcxproj +++ b/AirLibUnitTests/AirLibUnitTests.vcxproj @@ -31,26 +31,26 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode @@ -138,7 +138,7 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) $(ProjectDir)..\AirLib\deps\eigen3;$(ProjectDir)..\AirLib\include;$(ProjectDir)..\MavLinkCom\include - true + false /w34263 /w34266 %(AdditionalOptions) @@ -160,7 +160,7 @@ true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) $(ProjectDir)..\AirLib\deps\eigen3;$(ProjectDir)..\AirLib\include;$(ProjectDir)..\MavLinkCom\include - true + false /w34263 /w34266 %(AdditionalOptions) diff --git a/DroneServer/DroneServer.vcxproj b/DroneServer/DroneServer.vcxproj index 8254af722..60d3f6c02 100644 --- a/DroneServer/DroneServer.vcxproj +++ b/DroneServer/DroneServer.vcxproj @@ -39,26 +39,26 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/DroneShell/DroneShell.vcxproj b/DroneShell/DroneShell.vcxproj index b15f08669..6586fdde4 100644 --- a/DroneShell/DroneShell.vcxproj +++ b/DroneShell/DroneShell.vcxproj @@ -1,6 +1,6 @@  - + true @@ -31,26 +31,26 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/Examples/Examples.vcxproj b/Examples/Examples.vcxproj index 5a609d933..9abf2ee0d 100644 --- a/Examples/Examples.vcxproj +++ b/Examples/Examples.vcxproj @@ -45,26 +45,26 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/HelloCar/HelloCar.vcxproj b/HelloCar/HelloCar.vcxproj index c24e862b8..89977f0df 100644 --- a/HelloCar/HelloCar.vcxproj +++ b/HelloCar/HelloCar.vcxproj @@ -42,26 +42,26 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/HelloDrone/HelloDrone.vcxproj b/HelloDrone/HelloDrone.vcxproj index cd59ed34c..89681b335 100644 --- a/HelloDrone/HelloDrone.vcxproj +++ b/HelloDrone/HelloDrone.vcxproj @@ -42,26 +42,26 @@ Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode Application true - v141 + v142 Unicode Application false - v141 + v142 true Unicode diff --git a/MavLinkCom/MavLinkCom.vcxproj b/MavLinkCom/MavLinkCom.vcxproj index 85b2b293e..f322ff48d 100644 --- a/MavLinkCom/MavLinkCom.vcxproj +++ b/MavLinkCom/MavLinkCom.vcxproj @@ -3,7 +3,7 @@ true - v141 + v142 @@ -136,6 +136,7 @@ common_utils;include true true + stdcpp17 Console @@ -205,6 +206,7 @@ common_utils;include true true + stdcpp17 Console @@ -242,6 +244,7 @@ MultiThreadedDLL common_utils;include true + stdcpp17 Console @@ -312,6 +315,7 @@ common_utils;include true true + stdcpp17 Console diff --git a/MavLinkCom/MavLinkTest/Commands.cpp b/MavLinkCom/MavLinkTest/Commands.cpp index 90a630480..e353dfa57 100644 --- a/MavLinkCom/MavLinkTest/Commands.cpp +++ b/MavLinkCom/MavLinkTest/Commands.cpp @@ -10,9 +10,10 @@ #include #include "FileSystem.hpp" #include "Utils.hpp" +#include #if defined(_WIN32) || ((defined __cplusplus) && (__cplusplus >= 201700L)) -#include + #define USE_CPP_FILESYSTEM #else #undef USE_CPP_FILESYSTEM @@ -466,14 +467,8 @@ void DumpLogCommandsCommand::processLogCommands(MavLinkFileLog& log, const std:: void DumpLogCommandsCommand::Execute(std::shared_ptr com) { unused(com); -//TODO: make below future proof (i.e. usable by C++17 compiler) - also change same in main.cpp -#if defined(USE_CPP_FILESYSTEM) -//can't use experimental stuff on Linux because of potential ABI issues -#if defined(_WIN32) || ((defined __cplusplus) && (__cplusplus < 201700L)) - using namespace std::experimental::filesystem; -#else + using namespace std::filesystem; -#endif path dirPath(log_folder_); @@ -491,9 +486,6 @@ void DumpLogCommandsCommand::Execute(std::shared_ptr com) } printf("dumplogcommands is done\n"); -#else - printf("dumplogcommands is available only with C++17 features\n"); -#endif } diff --git a/MavLinkCom/MavLinkTest/MavLinkTest.vcxproj b/MavLinkCom/MavLinkTest/MavLinkTest.vcxproj index f36a5cae3..263a20274 100644 --- a/MavLinkCom/MavLinkTest/MavLinkTest.vcxproj +++ b/MavLinkCom/MavLinkTest/MavLinkTest.vcxproj @@ -28,7 +28,7 @@ - v141 + v142 {25EB67BE-468A-4AA5-910F-07EFD58C5516} @@ -134,6 +134,7 @@ MultiThreadedDebugDLL true true + stdcpp17 Console @@ -183,6 +184,7 @@ MultiThreadedDebugDLL true true + stdcpp17 Console @@ -208,6 +210,7 @@ ../include;../common_utils; MultiThreadedDLL true + stdcpp17 Console @@ -256,6 +259,7 @@ MultiThreadedDLL true true + stdcpp17 Console diff --git a/MavLinkCom/MavLinkTest/main.cpp b/MavLinkCom/MavLinkTest/main.cpp index ebb6528e0..52a98f50b 100644 --- a/MavLinkCom/MavLinkTest/main.cpp +++ b/MavLinkCom/MavLinkTest/main.cpp @@ -22,7 +22,7 @@ STRICT_MODE_OFF STRICT_MODE_ON #include "UnitTests.h" -#if defined(_WIN32) || ((defined __cplusplus) && (__cplusplus >= 201700L)) +#if defined(_WIN32) #include #define USE_CPP_FILESYSTEM #else @@ -154,11 +154,6 @@ std::shared_ptr mavLinkVehicle; #if defined(USE_CPP_FILESYSTEM) - -//can't use experimental stuff on Linux because of potential ABI issues -#if defined(_WIN32) || ((defined __cplusplus) && (__cplusplus < 201700L)) -using namespace std::experimental::filesystem; -#else using namespace std::filesystem; #endif @@ -393,9 +388,6 @@ void ConvertLogFilesToCsv(std::string directory) } } - -#endif - void OpenLogFiles() { if (logDirectory.size() > 0) { @@ -1033,7 +1025,14 @@ std::string findPixhawk() { if (info.pid == pixhawkFMUV4ProductId || info.pid == pixhawkFMUV2ProductId || info.pid == pixhawkFMUV2OldBootloaderProductId) { printf("Auto Selecting COM port: %S\n", info.displayName.c_str()); - return std::string(info.portName.begin(), info.portName.end()); + + std::string portName_str; + + for (wchar_t ch : info.portName) + { + portName_str.push_back(static_cast(ch)); + } + return portName_str; } } } diff --git a/MavLinkCom/common_utils/ThreadUtils.cpp b/MavLinkCom/common_utils/ThreadUtils.cpp index 5f21bdd97..2c9c28711 100644 --- a/MavLinkCom/common_utils/ThreadUtils.cpp +++ b/MavLinkCom/common_utils/ThreadUtils.cpp @@ -57,9 +57,12 @@ bool CurrentThread::setThreadName(const std::string& name) } } if (setThreadDescriptionFunction != nullptr) { - std::wstring_convert, wchar_t> converter; - std::wstring wide_path = converter.from_bytes(name.c_str()); - return S_OK == (*setThreadDescriptionFunction)(GetCurrentThread(), wide_path.c_str()); + const char* str = name.c_str(); + int size_needed = MultiByteToWideChar(CP_UTF8, 0, str, (int)strlen(str), NULL, 0); + WCHAR* wstrTo = (WCHAR*)malloc(size_needed); + MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)strlen(str), wstrTo, size_needed); + + return S_OK == (*setThreadDescriptionFunction)(GetCurrentThread(), wstrTo); } return false; #elif defined(__APPLE__) diff --git a/MavLinkCom/common_utils/ThreadUtils.hpp b/MavLinkCom/common_utils/ThreadUtils.hpp index 1a89d69da..97cfedbac 100644 --- a/MavLinkCom/common_utils/ThreadUtils.hpp +++ b/MavLinkCom/common_utils/ThreadUtils.hpp @@ -2,6 +2,7 @@ #define MavLinkCom_HighPriorityThread_hpp #include +#include namespace mavlink_utils { diff --git a/SGM/src/sgmstereo/sgmstereo_vc15.vcxproj b/SGM/src/sgmstereo/sgmstereo_vc15.vcxproj index 1ea99c8b6..e1a70a59c 100644 --- a/SGM/src/sgmstereo/sgmstereo_vc15.vcxproj +++ b/SGM/src/sgmstereo/sgmstereo_vc15.vcxproj @@ -34,30 +34,30 @@ SAK SAK SAK - sgmstereo + sgmstereo StaticLibrary Unicode true - v141 + v142 StaticLibrary Unicode true - v141 + v142 StaticLibrary Unicode - v141 + v142 StaticLibrary Unicode - v141 + v142 @@ -110,7 +110,6 @@ Level4 ProgramDatabase NOMINMAX;_UNICODE;UNICODE;%(PreprocessorDefinitions) - false @@ -137,7 +136,6 @@ ProgramDatabase NOMINMAX;_UNICODE;UNICODE;%(PreprocessorDefinitions) true - true diff --git a/SGM/src/stereoPipeline/StateStereo.cpp b/SGM/src/stereoPipeline/StateStereo.cpp index 59b4596ee..5068ff92c 100644 --- a/SGM/src/stereoPipeline/StateStereo.cpp +++ b/SGM/src/stereoPipeline/StateStereo.cpp @@ -124,7 +124,7 @@ float CStateStereo::GetLeftDisparity(float x, float y) unsigned char c = confMap[off]; if (fabs(d) < ndisps && c >= confThreshold) { - return 1.0f - (fabs(d)/float(ndisps)); + return 1.0f - (float)(fabs(d)/ndisps); } else return -1.0f; diff --git a/SGM/src/stereoPipeline/stereoPipeline_vc15.vcxproj b/SGM/src/stereoPipeline/stereoPipeline_vc15.vcxproj index be1589fd2..b07ab6265 100644 --- a/SGM/src/stereoPipeline/stereoPipeline_vc15.vcxproj +++ b/SGM/src/stereoPipeline/stereoPipeline_vc15.vcxproj @@ -37,27 +37,27 @@ StaticLibrary true Unicode - v141 + v142 StaticLibrary true Unicode - v141 + v142 StaticLibrary false true Unicode - v141 + v142 StaticLibrary false true Unicode - v141 + v142 diff --git a/Unreal/Environments/Blocks/Blocks.uproject b/Unreal/Environments/Blocks/Blocks.uproject index 91f342120..3feb54162 100644 --- a/Unreal/Environments/Blocks/Blocks.uproject +++ b/Unreal/Environments/Blocks/Blocks.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "4.24", + "EngineAssociation": "4.22", "Category": "", "Description": "", "Modules": [ diff --git a/build.cmd b/build.cmd index 5efd49a83..8a6d76cca 100644 --- a/build.cmd +++ b/build.cmd @@ -78,7 +78,7 @@ ECHO Starting cmake to build rpclib... IF NOT EXIST external\rpclib\rpclib-2.2.1\build mkdir external\rpclib\rpclib-2.2.1\build cd external\rpclib\rpclib-2.2.1\build REM cmake -G"Visual Studio 14 2015 Win64" .. -cmake -G"Visual Studio 15 2017 Win64" .. +cmake -G"Visual Studio 16 2019" .. if "%buildMode%" == "--Debug" ( cmake --build . --config Debug diff --git a/cmake/MavLinkCom/CMakeLists.txt b/cmake/MavLinkCom/CMakeLists.txt index 7743eb8b9..02a3ae64b 100644 --- a/cmake/MavLinkCom/CMakeLists.txt +++ b/cmake/MavLinkCom/CMakeLists.txt @@ -48,6 +48,8 @@ ELSE() LIST(APPEND MAVLINK_SOURCES "${AIRSIM_ROOT}/MavLinkCom/src/impl/windows/WindowsFindSerialPorts.cpp") ENDIF() + + add_library(MavLinkCom STATIC ${MAVLINK_SOURCES}) CommonTargetLink() diff --git a/cmake/MavLinkCom/MavLinkTest/CMakeLists.txt b/cmake/MavLinkCom/MavLinkTest/CMakeLists.txt index e361ecb8e..e7b072fed 100644 --- a/cmake/MavLinkCom/MavLinkTest/CMakeLists.txt +++ b/cmake/MavLinkCom/MavLinkTest/CMakeLists.txt @@ -16,5 +16,7 @@ include_directories( set(PROJECT_CPP ${PROJECT_NAME}_sources) file(GLOB_RECURSE PROJECT_CPP "${AIRSIM_ROOT}/MavLinkCom/${PROJECT_NAME}/*.cpp") add_executable(${PROJECT_NAME} ${PROJECT_CPP}) + +target_compile_features(MavlinkTest PRIVATE cxx_std_17) target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} MavLinkCom ${CXX_EXP_LIB})