Skip to content

Make 64-bit int work with 'long int' and 'int64_t' for 64 bit builds (Issue #64) #65

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

Closed
wants to merge 3 commits into from

Conversation

orodbhen
Copy link

@orodbhen orodbhen commented Nov 7, 2014

This should fix this issue.

@cdunn2001
Copy link
Contributor

Revert this if you want, Billy. And do what you think best.

Minimally, I'll revert this on the preC++11 branch. On master, I want to assume C++11 from now on.

@orodbhen
Copy link
Author

orodbhen commented Nov 9, 2014

This should at least work in the C++11 branch, like this:

#include <cstdint>
namespace Json {
typedef int Int;
typedef unsigned int UInt;
#if defined(JSON_NO_INT64)
typedef int LargestInt;
typedef unsigned int LargestUInt;
#undef JSON_HAS_INT64
#else                 // if defined(JSON_NO_INT64)
// For Microsoft Visual use specific types as long long is not supported
#if defined(_MSC_VER) // Microsoft Visual Studio
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#elif __cplusplus >= 201103L // Using C++11
typedef int64_t Int64;
typedef uint64_t UInt64;
#else               // Other platforms, use long long
typedef long long Int64;
typedef unsigned long long Uint64;
#endif // if defined(_MSC_VER)

@BillyDonahue
Copy link
Contributor

I think you'd want to put the C++11 check up front.

If you're in C++11, you're done. It's std::uint64_t, and it's all gravy.

Only if you're not in C++11 do you need to get desperate and use things like __int64 or long long, depending on the compiler.

@cdunn2001
Copy link
Contributor

This does not even pass Travis CI! But I've pulled your commits into Billy's accept_all_arithmetic_types branch for historical reference. See #66.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants