-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Do not use [[nodiscard]]
attribute on compiler not supporting it.
#1003
Conversation
41e0b2a
to
77c5f5c
Compare
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.
The NODISCARD
macro is introduced under the implicit assumption that libkiwix
is the only project having run into the portability issue of direct usage of the [[nodiscard]]
C++ attribute (I mean what if e.g. xapian defines such a macro too?)
I see two reasonable options out of the current situation:
- Drop the (only current usage of the)
[[nodiscard]]
attribute. - Think about supporting it in a better way and define the appropriate macro (along with other useful general purpose macros) in a header file of its own (which may better belong to
libzim
).
include/library.h
Outdated
@@ -34,6 +34,14 @@ | |||
|
|||
#define KIWIX_LIBRARY_VERSION "20110515" | |||
|
|||
#define NODISCARD | |||
#if defined __has_cpp_attribute | |||
#if __has_attribute (nodiscard) |
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.
Shouldn't this be __has_cpp_attribute
for better portability (and consistency with the above check)?
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.
Yes
What about renaming
The frontier is a bit blurry but we want to keep the two projects separated. |
That will do, but the next question is "Why does it have to be defined in
I don't see why the usage of |
It doesn't have to be defined here, but it is used only in
The purpose of libzim is not to provide useful things to other projects. It is to provide reading and writing zim files (and even that, we want to split libzim in two libraries openzim/libzim#789)
Droping the |
So that it is easier to reuse if/when needed somewhere else. If you care only about |
77c5f5c
to
ba45a59
Compare
New version:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1003 +/- ##
=======================================
Coverage 38.92% 38.92%
=======================================
Files 58 58
Lines 3990 3990
Branches 2201 2201
=======================================
Hits 1553 1553
Misses 1090 1090
Partials 1347 1347 ☔ View full report in Codecov by Sentry. |
On aarch64, we use gcc version 6.3.0 which doesn't support the `[[nodiscard]]` attribute (see https://en.cppreference.com/w/cpp/compiler_support/17) So don't set the attribute if the attribute is not present.
ba45a59
to
01aa190
Compare
On aarch64, we use gcc version 6.3.0 which doesn't support the
[[nodiscard]]
attribute(see https://en.cppreference.com/w/cpp/compiler_support/17)
So don't set the attribute if the attribute is not present.