-
Notifications
You must be signed in to change notification settings - Fork 310
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
MSVC compatibility for vcpkg #266
Conversation
…(rare) This prevents a bug class where we bswap things when __LITTLE_ENDIAN__ is not defined. Almost all modern systems are little endian, so detecting __BIG_ENDIAN__ is a better strategy.
@@ -343,7 +389,7 @@ static char *plist_utf16be_to_utf8(uint16_t *unistr, long len, long *items_read, | |||
} | |||
|
|||
while (i < len) { | |||
wc = be16toh(get_unaligned(unistr + i)); | |||
wc = UINT_TO_HOST(unistr + i, sizeof(wc)); |
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.
Getting this:
bplist.c:392:18: warning: pointer type mismatch ('const char *' and 'uint16_t *' (aka 'unsigned short *')) [-Wpointer-type-mismatch]
wc = (uint16_t)UINT_TO_HOST(unistr + i, sizeof(wc));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bplist.c:190:24: note: expanded from macro 'UINT_TO_HOST'
__up.src = ((n) > 8) ? (const char*)(x) + ((n) - 8) : (x); \
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~
1 warning generated.```
src/bplist.c
Outdated
#define UINT_TO_HOST(x, n) \ | ||
({ \ | ||
union plist_uint_ptr __up; \ | ||
__up.src = ((n) > 8) ? (x) + ((n) - 8) : (x); \ | ||
__up.src = ((n) > 8) ? (const char*)(x) + ((n) - 8) : (x); \ |
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.
See comment below. I think we need another cast, like this:
__up.src = ((n) > 8) ? (const char*)(x) + ((n) - 8) : (const char*)(x);
And maybe in the _MSC_VER variant too.
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.
it does pass all checks though when I remove the cast you put there.
Closes #76