-
Notifications
You must be signed in to change notification settings - Fork 449
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
Visual Studio compiler warnings clean-up #315
Visual Studio compiler warnings clean-up #315
Conversation
… - ignore if either of these isn't found
…try-cpp into maxgolov/compiler_warnings
Codecov Report
@@ Coverage Diff @@
## master #315 +/- ##
=======================================
Coverage 94.59% 94.60%
=======================================
Files 146 146
Lines 6629 6633 +4
=======================================
+ Hits 6271 6275 +4
Misses 358 358
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Formatter on my Ubuntu 20.xx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, otherwise this looks ok to me.
namespace std | ||
{ | ||
template <> | ||
struct hash<OPENTELEMETRY_NAMESPACE::nostd::string_view> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary for VS2015?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry, this is a template that allows to use nostd::string_view
as key in the std::map<nostd::string_view, ...>
.. It's adding the missing functionality that otherwise exists for std::string_view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I meant under the couple helper routines
umbrella in the PR description 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Practical reason why I'm adding this: I'm working on a swap between nostd::
vs. std::
vs. absl::
... Abseil will actually be required for Visual Studio 2015 (that's the only way how I can make backport of std::variant
work). Some changes like this one, and adding a few headers here and there - are aligning overall code to potentially work with any replacement / substitute for nostd::
. Once this PR is merged, I'll follow-up to refresh my other PR with support for:
nostd::
- default for anything vs2017+ and other OS.std::
with msgsl - option for any compiler that supports C++17 and above, for customers who want to statically link the SDK and don't want to dynamically load prebuilt tracers.absl::
- exotic flavor, currently only required for vs2015 (at least for the proper variant backport).
We can also potentially discuss that maybe we should switch from our nostd::variant
to absl::variant
, as Abseil's variant is at least definitely working on older compilers where ours is failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently have all tests passing for nostd::
, std::
+ absl::
for Vs2015 in my branch here:
https://github.com/maxgolov/opentelemetry-cpp
I'm doing a matrix build with OpenTelemetry-provided containers vs. Standard Library Containers vs. Abseil (for vs2015 only).
sdk/include/opentelemetry/sdk/metrics/aggregator/sketch_aggregator.h
Outdated
Show resolved
Hide resolved
I would prefer to keep the loop variables as (signed) ints and remove the warning flag instead. Context: https://google.github.io/styleguide/cppguide.html#Integer_Types |
This same rule says |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Partially addresses #249
Main goals:
size_t
instead ofint
for any index variable, even in tests. It's a bad coding practice to use signed integers for array index.std::
andabsl::
alternatives tonostd::
classes where needed.I'll send in a separate PR for setting up CI for Visual Studio 2015, with
Warnings Level 4
enabled, and subsequently breaking the build if somebody introduces a warning. That separate PR will also depend on replacingnostd::variant
byabsl::variant
, because our built-in backport ofnostd::variant
is not good ( see #314 ). Currently I'm testing out that flow in my fork.What is not addressed yet:
Since this will require refactor in the Metrics API, I am not touching those warnings, although they are actually "Level 2" warnings.