-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
g++/gcc-8 compatibility tweak for <bit> library header #1398
Comments
This is really working around a bug in GCC 8 right? (in that it pre-empted the final decision). Any reason not just to upgrade the CI/CD pipeline to GCC 9+ or Clang 10+ ? |
Changed in above commit. That doesn't seem work for Clang, but until nobody needs that, it'll be ok. |
I have no problems with some |
Thaks for the fix @farindk !
In the description above @pcdion forgot to quote the code, so #if (defined(__GNUC__) && __GNUC__ < 9) || (defined(__clang__) && __clang_major__ < 10)
#include <type_traits>
#else
#include <bit>
#endif
I would call it a limitation rather than a bug (GCC 8 is otherwise capable of building libheif). C++ 20 support in GCC is still marked as experimental even in the very latest compiler. From https://gcc.gnu.org/projects/cxx-status.html#cxx20 :
Even for C++ 17:
The main reason is that it would take a lot of time which we are not ready to invest right now (several inter-dependent projects). Building on an older system also maximizes compatibility to deploy on both older and newer systems. We unfortunately already had to spend a lot of efforts to upgrade to GCC 8 (for Windows / MinGW-w64 builds in particular). I find it ironic that C++ makes you rely on cutting-edge standard and experimental compiler features to detect the relic of the past that is big-endianness :) |
I changed the
Better late than never. |
As Clang (and Intel, PGI and maybe others) also define From https://sourceforge.net/p/predef/wiki/Compilers/
|
Thanks @kmilos for pointing this out... (GNU extensions vs. GCC compiler). I guess something like this would be needed: #define GCC_COMPILER (defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__PGI))
#if (defined(GCC_COMPILER) && __GNUC__ < 9) || (defined(__clang__) && __clang_major__ < 10)
#include <type_traits>
#else
#include <bit>
#endif See also https://stackoverflow.com/questions/28166565/detect-gcc-as-opposed-to-msvc-clang-with-macro . |
That's probably longer than the |
#define IS_BIG_ENDIAN (!*(unsigned char *)&(uint16_t){1}) which also says:
Sorry to have opened this can of worms ;) I blame this moving of a feature implemented in multiple major compiler releases to a different header though. |
Thanks |
To further complicate it, I think this has broken the AppVeyor build: https://ci.appveyor.com/project/strukturag/libheif/builds/51041650/job/8g8ocxxntdd4b5vp I think we need |
Thanks @bradh and sorry again for all the troubles. Otherwise Or perhaps this is a case of an older MSVC compiler that needs a similar compatibility fix? |
The above fixes the compiler version detection. The second line |
We are using gcc-8 for CI/CD, which supports C++20 features. While troubleshooting a build error, I came across the following:
Note: std::endian began in <type_traits>, but it [was moved](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1612r1.pdf) to <bit> at the 2019 Cologne meeting. GCC 8, Clang 7, 8 and 9 have it in <type_traits> while GCC 9+ and Clang 10+ have it in <bit>.
-- https://stackoverflow.com/questions/1001307/detecting-endianness-programmatically-in-a-c-programIn decoder_abstract.cc and bitstream.cc, this tweak can overcome the issue:
#if defined(GNUC) && GNUC < 9
#include <type_traits>
#else
#include
#endif
Would it be possible to include something like that?
Thanks
@farindk
The text was updated successfully, but these errors were encountered: