-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Warnings with Visual Studio c++ (VS2015 Update 3) #453
Comments
Interesting - it seems as if MSVC treats number literals like |
Adding another cast to all add_to_vector 8-bytes shift solve warning C4293
The 8-bytes add_to_vector however is never executed for string,object and array when targeting x86 on msvc since the size_type = size_t = 32bits. This (probably a dirty) fix works for me since I don't use large json data that exceeds 4GB. |
or more readable:
case 8:
{
uint64_t n = number; // casts by itself
vec.push_back(static_cast<uint8_t>((n >> 070) & 0xff));
vec.push_back(static_cast<uint8_t>((n >> 060) & 0xff));
vec.push_back(static_cast<uint8_t>((n >> 050) & 0xff));
vec.push_back(static_cast<uint8_t>((n >> 040) & 0xff));
// intentional fall-through
}
And it also happens on x86 code, of course, when you're storing large
values like database Indices.
|
Both warnings to not occur any more. I think this can be closed, right? |
Confirmed! Thanks! Also on gcc 4.9.2, (raspian 4.9.2-10) where similar warnings occured. |
When using the library with uint64_t values, some specialisations throw al lot of warnings (4267 and 4293).
The resulting code works fine, but I like a clean build log :)
So I propose to add the following lines before the first namespace Definition (line 103):
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable: 4267 4293)
#endif
and this at the end before the last #endif:
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
This also could be solved with type casts, but I think they would make the code less readable.
The text was updated successfully, but these errors were encountered: