-
Notifications
You must be signed in to change notification settings - Fork 257
Fix: Define GPR_ASSERT macro for compatibility #660
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
base: master
Are you sure you want to change the base?
Conversation
Welcome @nikurt! It looks like this is your first PR to tikv/grpc-rs 🎉 |
Added a fallback definition for GPR_ASSERT using <assert.h> to handle cases where it is not predefined. This ensures smoother compilation and avoids potential issues with missing assertions. Signed-off-by: Nikolay Kurtov <[email protected]> Signed-off-by: Nikolay Kurtov <[email protected]>
@@ -66,6 +66,11 @@ | |||
#define GPR_CALLTYPE | |||
#endif | |||
|
|||
#ifndef GPR_ASSERT | |||
#include <assert.h> |
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.
How about switching to absl check just like what upstream did?
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.
Thanks for the suggestion, haven't thought of that.
Observations:
absl/log/absl_check.h
has a static assert that the C++ variant is at least C++14ABSL_CHECK
depends onusing string_view = std::string_view
which is only available in C++17.
Attempted a prototype #661 which upgrades C++ to C++14, but can't make it compile.
A different prototype #662 upgrades C++ to C++17 and it compiles.
Here is what happens with a C++14 upgrade:
% cargo build
Compiling grpcio-sys v0.13.0+1.56.2-patched (/home/nkurtov/code/grpc-rs/grpc-sys)
warning: [email protected]+1.56.2-patched: In file included from /usr/include/absl/log/internal/nullstream.h:37,
warning: [email protected]+1.56.2-patched: from /usr/include/absl/log/internal/check_op.h:40,
warning: [email protected]+1.56.2-patched: from /usr/include/absl/log/internal/check_impl.h:19,
warning: [email protected]+1.56.2-patched: from /usr/include/absl/log/absl_check.h:38,
warning: [email protected]+1.56.2-patched: from grpc_wrap.cc:71:
warning: [email protected]+1.56.2-patched: /usr/include/absl/strings/string_view.h:53:26: error: 'string_view' in namespace 'std' does not name a type
warning: [email protected]+1.56.2-patched: 53 | using string_view = std::string_view;
warning: [email protected]+1.56.2-patched: | ^~~~~~~~~~~
warning: [email protected]+1.56.2-patched: /usr/include/absl/strings/string_view.h:53:21: note: 'std::string_view' is only available from C++17 onwards
warning: [email protected]+1.56.2-patched: 53 | using string_view = std::string_view;
warning: [email protected]+1.56.2-patched: | ^~~
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 see. Upgrading C++ standard will introduce breaking change, let's keep it this way for now.
Added a fallback definition for GPR_ASSERT using <assert.h> to handle cases where it is not predefined. This ensures smoother compilation and avoids potential issues with missing assertions.
Fixes #659