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

Many tests do not build on Windows #639

Open
laguerreche opened this issue Dec 12, 2024 · 0 comments
Open

Many tests do not build on Windows #639

laguerreche opened this issue Dec 12, 2024 · 0 comments

Comments

@laguerreche
Copy link

I cannot build tests because of the inclusion of Windows.h that is known to define the min() and max() macros.

For example, in the file swept_sphere_radius.cpp, there's the following inclusion:
#include <boost/test/included/unit_test.hpp>
that will eventually lead to the inclusion of the file boost\test\utils\setcolor.hpp which itself contains (line ~31 with Boost 1.84):

#ifdef _WIN32
  #include <windows.h>

During compilation, Visual Studio 2019 complains that max needs more arguments:

1>C:\Users\lolo\Devs\Coal\coal\test\swept_sphere_radius.cpp(310,68): warning C4003: not enough arguments for function-like macro invocation 'max'
1>C:\Users\lolo\Devs\Coal\coal\test\swept_sphere_radius.cpp(191,1): error C2589: '(': illegal token on right side of '::'

I suggest to add these lines in each test file that may be affected:

#define NOMINMAX   // <-- adding this line
#define WIN32_LEAN_AND_MEAN   // <-- not mandatory but should speed-up compilation
#define BOOST_TEST_MODULE COAL_SWEPT_SPHERE_RADIUS

#include <boost/test/included/unit_test.hpp>

As a side note, I recommend to define WIN32_LEAN_AND_MEAN in utility.h (I added guards against redefinitions):

#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#  define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX
#  define NOMINMAX
#endif
#include <Windows.h>
#else
#include <sys/time.h>
#endif
@laguerreche laguerreche changed the title Many tests do no build on Windows Many tests do not build on Windows Dec 12, 2024
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

No branches or pull requests

1 participant