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

Add macros for creating null-terminated string literals #1891

Merged
merged 10 commits into from Jul 12, 2022
Merged

Conversation

kennykerr
Copy link
Collaborator

@kennykerr kennykerr commented Jul 12, 2022

This update adds simple s! and w! macros that produce null terminated UTF8 and UTF16 string literals that supports both Win32 and WinRT APIs. This is quite convenient as Rust does not provide null terminated string literals nor does it provide UTF16 literals. The resulting expressions point to const data that is both folded by the compiler and stored in constant pages.

Fixes #484
Fixes #581

@kennykerr kennykerr requested a review from rylev July 12, 2022 05:16
@kennykerr kennykerr changed the title Literals Add macros for creating null-terminated string literals Jul 12, 2022
Copy link
Contributor

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Looks good! I do have some nits though.

crates/libs/windows/src/core/hstring.rs Outdated Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Outdated Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Outdated Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Show resolved Hide resolved
crates/libs/windows/src/core/literals.rs Show resolved Hide resolved
rylev
rylev previously approved these changes Jul 12, 2022
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.

Create PWSTR and PSTR from literals Support wide strings
2 participants