Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Limbo to work on windows. #324

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nickanthony-dgl
Copy link

This PR makes 2 minor changes to allow Limbo to compile on a Windows machine. These changes are guarded by the #ifdef _WIN32 preprocessor so they will not affect non-Windows builds.

  • In "limbo/model/gp.hpp" includes "corecrt_math_defines.h" so that the M_PI preprocessor define will be defined
  • In "limbo/tools/sys.hpp" "windows.h" is included instead of "unistd.h" and the "GetComputerNameA" function is used instead of "unistd.h"'s "gethostname" function.

Copy link
Member

@costashatz costashatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickanthony-dgl thanks a lot for this PR. Great that limbo works in Windows as well with so little changes :) See one minor improvement requested. Thanks again! 😄

@@ -46,6 +46,10 @@
#ifndef LIMBO_MODEL_GP_HPP
#define LIMBO_MODEL_GP_HPP

#ifdef _WIN32
#include <corecrt_math_defines.h> // This brings in the M_PI define which is not in the C or C++ standard.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer the following alternative:

#define _USE_MATH_DEFINES
#include <cmath>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't appear to be working for me, I get "M_PI": identifier not found. I think the issue is that if <cmath> has already been included somewhere earlier in the compilation then:

#define _USE_MATH_DEFINES
#include <cmath>

will have no effect. You have to make sure that #define _USE_MATH_DEFINES happens before the first inclusion of <cmath> which can be difficult for a header-only library.

This same issue is discussed here and here

How would you feel about skipping the use of the M_PI preprocessor constant altogether and instead use something like:

namespace limbo {
  constexpr double PI = 3.14159265359;
  ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most probably you need to put it here: https://github.com/resibots/limbo/blob/master/src/limbo/tools/math.hpp#L50. If this is not working, please enabling editing by admins for the PR and I will make the define from waf to be globally defined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about skipping the use of the M_PI preprocessor constant altogether and instead use something like

My issue with that is that we would need to define a bigger set of constants, otherwise we are inconsistent. And this is a Windows issue. We will find a way to by-pass it.

Copy link
Author

@nickanthony-dgl nickanthony-dgl Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putting it in math.hpp didn't work but putting it in bo_base.hpp (the only place I see where gp.hpp is used) did. Please see the most recent commit.

I will go ahead and enable editing on this PR. Edit: It looks like "Allow edits by maintainers" is already enabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the effort! I will try to have a look asap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants