Skip to content
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

Win32 build issue with Unicode #75

Open
walbourn opened this issue Feb 5, 2023 · 4 comments
Open

Win32 build issue with Unicode #75

walbourn opened this issue Feb 5, 2023 · 4 comments
Labels
Milestone

Comments

@walbourn
Copy link

walbourn commented Feb 5, 2023

Per the UTF-8 Everywhere Manifesto, it's best to not rely on the legacy ANSI .vs UNICODE macros for Win32 functions that take strings. Since you explicitly use an ANSI string for the call to LoadLibrary you should explicitly use the LoadLibraryA method.

This causes problems when trying to build your library using vcpkg manager when the setup adds the recommended UNICODE _UNICODE defines.

In exception.cpp use FormatMessageA instead of FormatMessage.

@fpagliughi
Copy link
Owner

fpagliughi commented Feb 8, 2023

Ugh. The Win32 API just confuses the hell out of me! But thanks for the tip. Let me know if you spot anything else. I'll look to get a little fix release out in the next few weeks.

BTW... If you have a suggestion for a better way to do this, let me know.

@fpagliughi fpagliughi added this to the v0.8.2 milestone Feb 8, 2023
@fpagliughi fpagliughi added the bug label Feb 8, 2023
@walbourn
Copy link
Author

walbourn commented Feb 8, 2023

Blame on back-compat with 16-bit Windows and the transition from ANSI to Unicode :)

LoadLibrary and FormatMessage aren't actually functions. They are just macros based on MBCS vs. UNICODE settings. By explicitly calling LoadLibraryA you are ignoring those crazy macros. For more information on why this is a 'best practice' these days, see UTF-8 Everywhere.

@fpagliughi
Copy link
Owner

Ha. Yeah, I'm so old, the last time I programmed Windows professionally, I was dealing with segments and offsets, not Unicode! I didn't realize those agnostic "functions" were actually macros. Thanks.

@walbourn
Copy link
Author

walbourn commented Feb 8, 2023

It's all part of the TCHAR and Uniscribe pain that was Windows 9x :)

@fpagliughi fpagliughi modified the milestones: v0.8.2, v0.9 Mar 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants