Skip to content

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
@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.

5 participants