From 870c7219db6e750c407e29753aaaee56dfcb02e2 Mon Sep 17 00:00:00 2001 From: nickanthony-dgl Date: Mon, 19 Dec 2022 17:42:54 -0600 Subject: [PATCH 1/3] Allow limbo to work on windows. --- src/limbo/model/gp.hpp | 4 ++++ src/limbo/tools/sys.hpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/limbo/model/gp.hpp b/src/limbo/model/gp.hpp index 3bfa4db5df..3e35540fed 100644 --- a/src/limbo/model/gp.hpp +++ b/src/limbo/model/gp.hpp @@ -46,6 +46,10 @@ #ifndef LIMBO_MODEL_GP_HPP #define LIMBO_MODEL_GP_HPP +#ifdef _WIN32 +#include // This brings in the M_PI define which is not in the C or C++ standard. +#endif + #include #include #include diff --git a/src/limbo/tools/sys.hpp b/src/limbo/tools/sys.hpp index 3bb8f8edf7..11e7f2e57b 100644 --- a/src/limbo/tools/sys.hpp +++ b/src/limbo/tools/sys.hpp @@ -49,7 +49,11 @@ #include #include +#ifdef _WIN32 +#include +#else #include +#endif namespace limbo { namespace tools { @@ -69,7 +73,12 @@ namespace limbo { inline std::string hostname() { char hostname[50]; +#ifdef _WIN32 + DWORD buffCharCount = 50; + int res = GetComputerNameA(hostname, &buffCharCount); +#else int res = gethostname(hostname, 50); +#endif assert(res == 0); res = 0; // avoid a warning in opt mode return std::string(hostname); From 0d0d1f263ddf525b0ed868e0804824c767676c0f Mon Sep 17 00:00:00 2001 From: nickanthony-dgl Date: Mon, 19 Dec 2022 17:54:45 -0600 Subject: [PATCH 2/3] fix assertion error --- src/limbo/tools/sys.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/limbo/tools/sys.hpp b/src/limbo/tools/sys.hpp index 11e7f2e57b..9dbfde243a 100644 --- a/src/limbo/tools/sys.hpp +++ b/src/limbo/tools/sys.hpp @@ -75,12 +75,14 @@ namespace limbo { char hostname[50]; #ifdef _WIN32 DWORD buffCharCount = 50; - int res = GetComputerNameA(hostname, &buffCharCount); + bool ok = GetComputerNameA(hostname, &buffCharCount); + assert(ok); #else int res = gethostname(hostname, 50); -#endif assert(res == 0); res = 0; // avoid a warning in opt mode +#endif + return std::string(hostname); } From 22b1a4a9d8d90ba4cd822ddb3499d27632fd4556 Mon Sep 17 00:00:00 2001 From: nickanthony-dgl Date: Tue, 20 Dec 2022 13:41:15 -0600 Subject: [PATCH 3/3] replace with use of _USE_MATH_DEFINES --- src/limbo/bayes_opt/bo_base.hpp | 1 + src/limbo/model/gp.hpp | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/limbo/bayes_opt/bo_base.hpp b/src/limbo/bayes_opt/bo_base.hpp index f87bece842..5b55d915cf 100644 --- a/src/limbo/bayes_opt/bo_base.hpp +++ b/src/limbo/bayes_opt/bo_base.hpp @@ -63,6 +63,7 @@ #include // we need everything to have the defaults +#define _USE_MATH_DEFINES // This makes sure to bring in the M_PI define which is not in the C or C++ standard and is not defined by default on Windows. #include #include #include diff --git a/src/limbo/model/gp.hpp b/src/limbo/model/gp.hpp index 3e35540fed..3bfa4db5df 100644 --- a/src/limbo/model/gp.hpp +++ b/src/limbo/model/gp.hpp @@ -46,10 +46,6 @@ #ifndef LIMBO_MODEL_GP_HPP #define LIMBO_MODEL_GP_HPP -#ifdef _WIN32 -#include // This brings in the M_PI define which is not in the C or C++ standard. -#endif - #include #include #include