-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add support for long and long long types #87
Comments
See https://en.cppreference.com/w/cpp/language/types for more info. |
Doing more research and playing around it looks like we can't make all of the types work portably. Specifically we are dealing with As shown in the link above - a It is important to remember that a type alias, such as Herein lies the problem. We can either have a consistent, portable definition of If we store
Alternatively, we can (and presently) do define a @RalphSteinhagen @mormj do you have any thoughts on the issue? I am leaning towards keeping the support for In we keep the
We would want to consider adding some special handling to the struct reflection so that structs could contain |
Wow. Very interesting - I had not thought about uint64_t being ambiguous. Your last recommendation makes sense - document additional precautions for using cstdint types across systems. As long as there is a way to do it, it seems that is the most consistent. size_t is inconsistent by design, so that should not be expected to work portably. Or maybe we should just use flatbuffers to serialize ;) |
😬 I think the proposal of primarily supporting the uintXX_t types is IMO sound. The conditions on Have to think about whether we could intercept |
They must be separate types – the former is signed, the latter unsigned.
This is not possible – #include <type_traits>
#include <cstdint>
#include <cstddef>
static_assert(std::is_signed_v<uint64_t>);
static_assert(std::is_signed_v<size_t>);
static_assert(std::is_same_v<long, uint64_t>); // long long on Windows
static_assert(std::is_same_v<long, size_t>); // long long on Windows
int main() {}
This is not true (and would make fixed width integer types completely pointless). From cppreference:
EDIT: Added comment in example code. |
I apologize there were a few typos in my previous message. I was not meaning to conflate signed and unsigned types. I think my errors caused you to miss the point. The issue is the same with both signed and unsigned long types. First we need to understand type aliases. https://en.cppreference.com/w/cpp/language/type_alias
Next, lets look at the data models. https://en.cppreference.com/w/cpp/language/types From the table in the middle of the page, we can see that with a compiler that uses an LLP64 Model that a Types such as From https://en.cppreference.com/w/cpp/types/integer - it specifies that a I don't have time now, but you can try this out in compiler explorer and verify for yourself. |
This issue was discovered when compiling a web assembly version of the library. It turns out that
long
andlong long
are sometimes separate types fromuint32_t
anduint64_t
(but not always). It depends on the system architecture width and the compiler.We are going to need to add support for these types conditionally if they are different than the other types. For example, in gcc11 on a 64 bit system, a
uint64_t
is the same as along
, butlong long
is a separate type. From looking at headers, it appears that that on a 32 bit system, along long
would be auint64_t
and along
would be a separate type.The text was updated successfully, but these errors were encountered: