From 0b384d2a5359da897b806b00fb901e7a6b7c4f83 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Thu, 2 May 2019 13:47:12 +0300 Subject: [PATCH] Get working in visual studio --- common/cpp/src/configuration.cpp | 5 +++++ net/cpp/include/ftl/net/peer.hpp | 4 ++++ net/cpp/include/ftl/net/universe.hpp | 4 ++++ net/cpp/src/peer.cpp | 9 +++++++++ net/cpp/src/uri.cpp | 1 + vision/src/main.cpp | 2 +- vision/src/middlebury.cpp | 3 ++- 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/common/cpp/src/configuration.cpp b/common/cpp/src/configuration.cpp index 51a58f034..d42d487e9 100644 --- a/common/cpp/src/configuration.cpp +++ b/common/cpp/src/configuration.cpp @@ -75,6 +75,7 @@ bool ftl::is_video(const string &file) { bool ftl::create_directory(const std::string &path) { #ifdef WIN32 // TODO(nick) + return false; #else if (!is_directory(path)) { int err = ::mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); @@ -167,7 +168,11 @@ static map<string, string> read_options(char ***argv, int *argc) { opts[cmd.substr(2)] = "true"; } else { auto val = cmd.substr(p+1); +#ifdef WIN32 + if ((val[0] >= 48 && val[0] <= 57) || val == "true" || val == "false" || val == "null") { +#else if (std::isdigit(val[0]) || val == "true" || val == "false" || val == "null") { +#endif opts[cmd.substr(2, p-2)] = val; } else { if (val[0] == '\\') opts[cmd.substr(2, p-2)] = val; diff --git a/net/cpp/include/ftl/net/peer.hpp b/net/cpp/include/ftl/net/peer.hpp index fb789a46b..da30ee520 100644 --- a/net/cpp/include/ftl/net/peer.hpp +++ b/net/cpp/include/ftl/net/peer.hpp @@ -1,6 +1,10 @@ #ifndef _FTL_NET_PEER_HPP_ #define _FTL_NET_PEER_HPP_ +#ifndef NOMINMAX +#define NOMINMAX +#endif + #ifndef WIN32 #define INVALID_SOCKET -1 #include <netinet/in.h> diff --git a/net/cpp/include/ftl/net/universe.hpp b/net/cpp/include/ftl/net/universe.hpp index f87694407..81f2a6f26 100644 --- a/net/cpp/include/ftl/net/universe.hpp +++ b/net/cpp/include/ftl/net/universe.hpp @@ -1,6 +1,10 @@ #ifndef _FTL_NET_UNIVERSE_HPP_ #define _FTL_NET_UNIVERSE_HPP_ +#ifdef _MSC_VER +#include <msgpack_optional.hpp> +#endif + #include <ftl/net/peer.hpp> #include <ftl/net/listener.hpp> #include <ftl/net/dispatcher.hpp> diff --git a/net/cpp/src/peer.cpp b/net/cpp/src/peer.cpp index 5c29ace9a..25a1721cb 100644 --- a/net/cpp/src/peer.cpp +++ b/net/cpp/src/peer.cpp @@ -2,6 +2,10 @@ #include <glog/logging.h> #include <ctpl_stl.h> +#ifndef NOMINMAX +#define NOMINMAX +#endif + #include <fcntl.h> #ifdef WIN32 #include <winsock2.h> @@ -9,6 +13,11 @@ #include <windows.h> #endif +#ifdef WIN32 +#pragma comment(lib, "Ws2_32.lib") +#pragma comment(lib, "Rpcrt4.lib") +#endif + #include <ftl/uri.hpp> #include <ftl/net/peer.hpp> #include <ftl/net/ws_internal.hpp> diff --git a/net/cpp/src/uri.cpp b/net/cpp/src/uri.cpp index 7add854f6..e23435246 100644 --- a/net/cpp/src/uri.cpp +++ b/net/cpp/src/uri.cpp @@ -1,6 +1,7 @@ #include <ftl/uri.hpp> using ftl::URI; +using ftl::uri_t; using std::string; URI::URI(uri_t puri) { diff --git a/vision/src/main.cpp b/vision/src/main.cpp index 59b61bae9..fbfcae649 100644 --- a/vision/src/main.cpp +++ b/vision/src/main.cpp @@ -7,7 +7,7 @@ #include <glog/logging.h> #include <ftl/configuration.hpp> #include <ctpl_stl.h> -#include <zlib.h> +// #include <zlib.h> #include <string> #include <map> diff --git a/vision/src/middlebury.cpp b/vision/src/middlebury.cpp index 9ad1e849f..85ec4a52b 100644 --- a/vision/src/middlebury.cpp +++ b/vision/src/middlebury.cpp @@ -10,6 +10,7 @@ using cv::Size; using std::string; using std::min; using std::max; +using std::isnan; static void skip_comment(FILE *fp) { // skip comment lines in the headers of pnm files @@ -195,7 +196,7 @@ void ftl::middlebury::evaldisp(const Mat &disp, const Mat >disp, const Mat &ma if (gt == INFINITY) // unknown continue; float d = scale * disp.at<float>(y / scale, x / scale, 0); - int valid = (!isnanf(d) && d < 256.0f); // NOTE: Is meant to be infinity in middlebury + int valid = (!isnan(d) && d < 256.0f); // NOTE: Is meant to be infinity in middlebury if (valid) { float maxd = scale * maxdisp; // max disp range d = max(0.0f, min(maxd, d)); // clip disps to max disp range -- GitLab