Skip to content

Document feature-test macros#2049

Merged
isaevil merged 7 commits intomasterfrom
dev/kboyarinov/feature-test-macros-docs
Apr 18, 2026
Merged

Document feature-test macros#2049
isaevil merged 7 commits intomasterfrom
dev/kboyarinov/feature-test-macros-docs

Conversation

@kboyarinov
Copy link
Copy Markdown
Contributor

Description

Add a table illustrating feature-test macros.
WARNING: The PR should be merged only once the PRs with features documentation are merged to avoid broken links

Fixes # - issue number(s) if exists

Type of change

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

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

  • 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

List users with @ to send notifications

Other information

#include <oneapi/tbb/version.h>
#include <oneapi/tbb/parallel_for.h>

#if TBB_HAS_PARALLEL_PHASE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since parallel_phase is currently a preview feature, it will not be available unless the preview macro is also set, which it isn't in this example. Is that intentional? Unfortunately, there are no feature test macros that currently guard non-preview features; otherwise, I'd suggest demonstrating with one of those.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, it is missing by accident. I added missing preview macro.


Each of these macros is defined in the header ``<oneapi/tbb/version.h>`` and in the feature headers
specified in the table below.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe add a paragraph explaining the relationship between preview features and feature test macros. For example, something like, "For preview features, the feature test macro will only be defined if the preview feature macro has been defined. You cannot use a feature test macro to guard the setting of a feature's preview macro."

And then maybe give a counter example like:

#include <oneapi/tbb/version.h>
#if TBB_HAS_FEATURE_X
#define TBB_PREVIEW_FEATURE_X
#include <feature_header.h>
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added suggested paragraph and also an example of incorrect/correct usage.

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@omalyshe omalyshe requested a review from vossmjp April 16, 2026 14:00
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
vossmjp
vossmjp previously approved these changes Apr 16, 2026
Copy link
Copy Markdown
Contributor

@vossmjp vossmjp left a comment

Choose a reason for hiding this comment

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

LGTM

parallel_loop2_body{});

#if TBB_HAS_PARALLEL_PHASE
tbb::this_task_arena::end_parallel_phase(/*with_fast_leave=*/true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It turns out that tbb::this_task_arena::end_parallel_phase(bool with_fast_leave) misses the default value for with_fast_leave parameter, which is actually mentioned in reference. I'll fix that in a separate PR and it shouldn't be a blocker for PR also.

Comment thread doc/main/reference/feature_test_macros.rst Outdated
Co-authored-by: Alexey Kukanov <alexey.kukanov@intel.com>
Comment thread doc/main/reference/feature_test_macros.rst Outdated
akukanov
akukanov previously approved these changes Apr 17, 2026
vossmjp
vossmjp previously approved these changes Apr 17, 2026
Copy link
Copy Markdown
Contributor

@vossmjp vossmjp left a comment

Choose a reason for hiding this comment

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

LGTM again

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@isaevil isaevil dismissed stale reviews from vossmjp and akukanov via 7268134 April 18, 2026 10:21
@isaevil isaevil merged commit 947a538 into master Apr 18, 2026
26 checks passed
@isaevil isaevil deleted the dev/kboyarinov/feature-test-macros-docs branch April 18, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants