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

Fix build error if defined _WIN32_WINNT #603

Merged
merged 1 commit into from
Oct 20, 2021

Conversation

phprus
Copy link
Contributor

@phprus phprus commented Oct 6, 2021

Description

Fix build error if defined _WIN32_WINNT

Fixes #565, #627, #628

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add respective label(s) to PR if you have permissions

  • bug fix - change which fixes an issue
  • new feature - change which adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and for some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

@anton-potapov

Other information

@alexey-katranov
Copy link
Contributor

Can you please show what exactly fails? Perhaps, it is not good testing strategy to define macros that users might not define.

@phprus
Copy link
Contributor Author

phprus commented Oct 7, 2021

Are you talking about NOMINMAX?
Without NOMINMAX, the macro max() are defined in windows.h.

This macro breaks the code:

oneTBB/test/common/doctest.h

Lines 5906 to 5908 in 6fad698

auto totwidth = int(std::ceil(log10((std::max(p.numTestCasesPassingFilters, static_cast<unsigned>(p.numAsserts))) + 1)));
auto passwidth = int(std::ceil(log10((std::max(p.numTestCasesPassingFilters - p.numTestCasesFailed, static_cast<unsigned>(p.numAsserts - p.numAssertsFailed))) + 1)));
auto failwidth = int(std::ceil(log10((std::max(p.numTestCasesFailed, static_cast<unsigned>(p.numAssertsFailed))) + 1)));

I can fix doctest.h or add undef for the macros max and min after #include <dbghelp.h>

Adding a test for a defined _WIN32_WINNT will require adding a new task to CI.

@alexey-katranov
Copy link
Contributor

alexey-katranov commented Oct 7, 2021

doctest.h already defines NOMINMAX but it is too late because of the order of includes,. Your patch seems the lesser of evils (at least not to refactor without any purpose).

@phprus
Copy link
Contributor Author

phprus commented Oct 7, 2021

I think maybe replace

#define NOMINMAX

to

#ifndef NOMINMAX
#define NOMINMAX
#endif

in my patch?

@alexey-katranov
Copy link
Contributor

It is not critical user observable code, so if the both approaches work, it is up to you what to choose.

@phprus
Copy link
Contributor Author

phprus commented Oct 7, 2021

Added #ifndef.

Copy link
Contributor

@anton-potapov anton-potapov left a comment

Choose a reason for hiding this comment

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

LGTM

@anton-potapov anton-potapov merged commit d439ddf into oneapi-src:master Oct 20, 2021
@phprus phprus deleted the issue-565 branch April 16, 2022 10:48
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.

Build error if defined _WIN32_WINNT
3 participants