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

Value-init fields of WinRT structs (fix warning C24695 in generated code) #1443

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

DefaultRyan
Copy link
Member

Current codegen was triggering Warning C24695 - Variable 'foo' is uninitialized.

This adds a default initializer to struct fields.

Before:

namespace winrt::Windows::UI::Xaml::Interop
{
    struct TypeName
    {
        hstring Name;
        winrt::Windows::UI::Xaml::Interop::TypeKind Kind;
    };
}

After:

namespace winrt::Windows::UI::Xaml::Interop
{
    struct TypeName
    {
        hstring Name {};
        winrt::Windows::UI::Xaml::Interop::TypeKind Kind {};
    };
}

Since consume* methods that return a struct are already value-initializing the return value, this has a negligible effect on the compiler codegen there. So that's nice.

@DefaultRyan DefaultRyan requested a review from Scottj1s October 29, 2024 18:00
@DefaultRyan DefaultRyan merged commit 2744f5c into master Oct 29, 2024
75 checks passed
@DefaultRyan DefaultRyan deleted the user/defaultryan/init-struct-fields branch October 29, 2024 21:40
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.

4 participants