libnpy icon indicating copy to clipboard operation
libnpy copied to clipboard

Does libnpy/1.0.1 support C++11?

Open toge opened this issue 2 years ago • 2 comments

Hi. I am writing a recipe for libnpy for a package manager called conan.

Let me ask a question that has arisen while writing the recipe.

Version 1.0.1 appears to be buildable in C++11. Does libnpy officially support C++14 and not C++11?

toge avatar Sep 19 '23 10:09 toge

I have not tested the compatibility with C++11 but I have not consciously used any features that would require C++14, either. If you don't get any compiler warnings, it should be fine.

llohse avatar Sep 20 '23 09:09 llohse

This code snippet: constexpr dtype_t has_typestring<float>::dtype; and the equivalent code for all other types, double, long double, int, etc. is problematic with C++11, because in C++11constexpr does not imply inline for non-static variables! That violates the One Definition Rule (ODR), so, multiple definitions fail to link.

I've done some more research on that, as I understand, there is a difference on the effect of constexpr on variables or functions between C++17 and C++11.

For functions, in C++17 & C++11, constexpr implies inline so there is no violation of the ODR. However, for non-static variables in C++11 constexpr does not imply inline!

ahadji05 avatar Jan 25 '24 10:01 ahadji05