Allow build for Universal Windows Platform#1340
Conversation
|
@microsoft-github-policy-service agree |
| #ifdef MI_WINDOWS_DESKTOP | ||
| hDll = LoadLibrary(TEXT("kernelbase.dll")); | ||
| #else | ||
| hDll = LoadPackagedLibrary(TEXT("kernelbase"), 0); |
There was a problem hiding this comment.
Might make sense to add a small helper function (eg _mi_prim_loadlibrary()) to avoid having a preprocessor condition for every occasion?
There was a problem hiding this comment.
It's more portable as it is now because it uses the TEXT macro and generic functions (LoadLibrary instead of LoadLibraryW/A) to be compiled interchangeably with or without UNICODE. If a helper function is created, it must have only one type of parameter, and this compatibility is broken.
Another reason is UWP library names are without the ".dll" termination (its not passed same exact text).
Finally, apart from purely cosmetic things, compiled code will always be more efficient without aux. functions.
There was a problem hiding this comment.
- The
TCHARtype is a thing. - Both the
LoadLibraryandLoadPackagedLibrarydocs state that, when the.dllextension is omitted, it's automatically added - so at least from reading the docs alone, either variant should be fine. - Inline functions are a thing.
Last but not least, if nothing else, you could provide a helper macro that takes care of the differences.
Allow build for Xbox Apps (UWP).
Currently
src/prim/windows/prim.chas some patches but only covers Xbox Games (not Apps).LoadLibraycannot be used in UWP apps, replaced withLoadPackagedLibrary.Also
WINAPI_PARTITION_APPis not defined for Xbox Games but is defined for Xbox Apps, then is not enough to cover all cases: console IO is also not available in Xbox Apps.This is also fixed.
Note that
WINAPI_PARTITION_APPis also defined when compile for Desktop then is not usable for differentiate Desktop / UWP.