Skip to content

Allow build for Universal Windows Platform#1340

Open
thexai wants to merge 1 commit into
microsoft:mainfrom
thexai:uwp
Open

Allow build for Universal Windows Platform#1340
thexai wants to merge 1 commit into
microsoft:mainfrom
thexai:uwp

Conversation

@thexai

@thexai thexai commented Jul 24, 2026

Copy link
Copy Markdown

Allow build for Xbox Apps (UWP).

Currently src/prim/windows/prim.c has some patches but only covers Xbox Games (not Apps).

LoadLibray cannot be used in UWP apps, replaced with LoadPackagedLibrary.

Also WINAPI_PARTITION_APP is 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_APP is also defined when compile for Desktop then is not usable for differentiate Desktop / UWP.

@thexai

thexai commented Jul 24, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Comment thread src/prim/windows/prim.c Outdated
#ifdef MI_WINDOWS_DESKTOP
hDll = LoadLibrary(TEXT("kernelbase.dll"));
#else
hDll = LoadPackagedLibrary(TEXT("kernelbase"), 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to add a small helper function (eg _mi_prim_loadlibrary()) to avoid having a preprocessor condition for every occasion?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The TCHAR type is a thing.
  2. Both the LoadLibrary and LoadPackagedLibrary docs state that, when the .dll extension is omitted, it's automatically added - so at least from reading the docs alone, either variant should be fine.
  3. Inline functions are a thing.

Last but not least, if nothing else, you could provide a helper macro that takes care of the differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants