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
Build warning - cast from pointer to integer of different size #133
base: master
Are you sure you want to change the base?
Build warning - cast from pointer to integer of different size #133
Conversation
39b3693
to
3d5de34
Compare
d509b2a
to
a04c7c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking alright so far, but the define will have to be changed since the standard(s) reserve(s) all names that contain two or more consecutive underscores (or also those that start with an underscore and then a capital letter). Changing the double underscore to a single underscore should suffice.
Ah, I knew about the leading underscore, not about the consecutive underscores. I can fix that. Is the code maybe getting too complex? Should we maybe live with the additional Also should I keep |
58e101d
to
5a1fc14
Compare
5a1fc14
to
3aa357f
Compare
I have also renamed |
It might be even easier to just copy the whole json_value struct into json.c and make a json_value_internal. Because the ifdefs you added are in the C++ helpers, which aren't available in the json_value visible to json.c anyway.
Nahh that would be admitting defeat ;-) |
Creating a Also, if some day we need to modify Finally, I feel it's more complicated for new maintainers to understand two distinct structs instead of one struct with |
The C++ helpers are visible by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good to me. I definitely agree that casting back and forth between a public and private structure could lead to all sorts of issues with maintainability. In either case though, the end result is some sort of violation of one thing or another. I'll have to do some testing to see how this plays out with ODR violations, but in theory it should be okay.
3aa357f
to
fa0cd92
Compare
fa0cd92
to
acb0071
Compare
Looks like this issue found its way into the VLC tracker! |
object->values used to be a size in pass 1 and a pointer in pass 2. A union has been added to avoid such GCC warning: * cast from pointer to integer of different size * dereferencing type-punned pointer will break strict-aliasing rules The union is visible only when JSON_PRVATE_API is defined, but this trick relies on sizeof(json_object_entry *) >= sizeof(unsigned int). The name of the new union is "_u" instead of "u", to make clear it is private.
acb0071
to
d2b61fc
Compare
Might fix #132.