Skip to content

Conversation

@aras-p
Copy link

@aras-p aras-p commented Dec 17, 2025

Description

Including <windows.h> is both 1) including a lot of code, and 2) leaving a lot of "damage" since it defines many things as preprocessor macros (e.g. far, near, GetObject etc. can't be used as identifiers).

In two cases that <windows.h> was used in TBB headers, the code needed only a tiny amount of functions, so just manually declare their prototypes:

The exact API shape of WinAPI functions (__declspec(dllimport), __stdcall) and their argument types realistically can't ever change, or it would break all existing software. So it should be fine to just declare them manually like this.

Fixes #573

Type of change

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

Tests

  • added - required for new features and 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

Other information

Including <windows.h> is both 1) including a lot of code, and
2) leaving a lot of "damage" since it defines many things as preprocessor
macros (e.g. "far", "near", "GetObject" etc. can't be used as identifiers).

In two cases that <windows.h> was used in TBB headers, the code needed
only a tiny amount of functions, so just manually declare their prototypes:

- _machine.h: just needs SwitchToThread(),
- enumerable_thread_specific.h: just needs four Tls functions (this
  achieves same result as uxlfoundation#576, but without any potential performance
  impacts due to extra function call).

The exact API shape of WinAPI functions (__declspec(dllimport), __stdcall)
and their argument types realistically can't ever change, or it would
break all existing software. So it should be fine to just declare them
manually like this.
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.

Remove <Windows.h> include from headers

1 participant