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

[BUILD] Remove defining NOMINMAX from api #2420

Merged
merged 3 commits into from
Dec 2, 2023

Conversation

ThomsonTan
Copy link
Contributor

@ThomsonTan ThomsonTan commented Nov 30, 2023

Currently, including OpenTelemetry API requires NOMINMAX to be defined for Windows user which excludes the min/max macro from the Windows header files. There are cases when both macros are used by the customer code so requiring NOMINMAX will cause incompatibility. This PR wraps the usage of min/max from C++ standard library with parenthesis. This can avoid the naming conflict with the macro names min/max.

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Merging #2420 (32979c4) into main (25343e6) will decrease coverage by 0.01%.
The diff coverage is 88.89%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2420      +/-   ##
==========================================
- Coverage   87.06%   87.04%   -0.01%     
==========================================
  Files         199      199              
  Lines        6079     6079              
==========================================
- Hits         5292     5291       -1     
- Misses        787      788       +1     
Files Coverage Δ
api/include/opentelemetry/common/spin_lock_mutex.h 25.00% <ø> (ø)
...de/opentelemetry/exporters/ostream/span_exporter.h 100.00% <ø> (ø)
sdk/include/opentelemetry/sdk/logs/processor.h 100.00% <ø> (ø)
...ry/sdk/metrics/aggregation/histogram_aggregation.h 91.31% <100.00%> (ø)
.../include/opentelemetry/sdk/metrics/metric_reader.h 50.00% <ø> (ø)
...opentelemetry/sdk/metrics/state/metric_collector.h 100.00% <ø> (ø)
sdk/src/logs/batch_log_record_processor.cc 87.50% <100.00%> (ø)
...k/src/metrics/aggregation/histogram_aggregation.cc 88.47% <100.00%> (ø)
...metrics/export/periodic_exporting_metric_reader.cc 79.35% <100.00%> (ø)
sdk/src/metrics/meter_context.cc 76.72% <100.00%> (ø)
... and 2 more

... and 1 file with indirect coverage changes

@ThomsonTan ThomsonTan marked this pull request as ready for review December 1, 2023 17:25
@ThomsonTan ThomsonTan requested a review from a team as a code owner December 1, 2023 17:25
Copy link
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

For the changes in API, totally agree, this is the most robust thing to do.

For the changes in exporters and SDK, I think the changes are not really needed, especially in *.cc because the Windows.h header file is not used and will not cause conflicts, but ok to have the extra parenthesis to have a consistent code.

Even when not needed, this will prevent two different styles to proliferate in the code base with copy and paste.

Approved, thanks for the fix.

@marcalff marcalff changed the title Remove defining NOMINMAX from api [BUILD] Remove defining NOMINMAX from api Dec 2, 2023
@ThomsonTan ThomsonTan merged commit abad83d into open-telemetry:main Dec 2, 2023
45 checks passed
@ThomsonTan ThomsonTan deleted the Remove_NOMINMAX_InAPI branch December 2, 2023 11:46
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.

3 participants