Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4070770
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:40:13+00:00 2026-05-20T16:40:13+00:00

I do a lot of Win32 programming in C++ and many Win32 structures have

  • 0

I do a lot of Win32 programming in C++ and many Win32 structures have a ‘size’ (often called cbSize or length) member as the first element which needs to be set before the relevant API call can be made. For example:

WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hWnd, &wp);

Now, I think it is good practice to initialize structure members to zero which I can do with:

WINDOWPLACEMENT wp = { };

or

WINDOWPLACEMENT wp = { 0 };

However, what happens to the other members of the struct if I initialize the first member like this:

WINDOWPLACEMENT wp = { sizeof(WINDOWPLACEMENT) };

Are they automatically initialized to zero? Or does it depend on which compiler I’m using and whether it’s a debug build or not?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:40:14+00:00Added an answer on May 20, 2026 at 4:40 pm

    Yes, they’re automatically initialized to zero.

    8.5.1/7:

    If there are fewer initializers in the
    list than there are members in the
    aggregate, then each member not
    explicitly initialized shall be
    value-initialized (8.5). [Example:

    struct S { int a; char* b; int c; };
    S ss = { 1, "asdf" };
    

    initializes ss.a with 1, ss.b with
    “asdf”, and ss.c with the value of an
    expression of the form int(), that is,
    0. ]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I don't do a lot of Win32 calls, but recently I have had
A lot of the time I will have a Business object that has a
A lot of programming languages and frameworks do/allow/require something that I can't seem to
I've noticed that in c/c++ a lot of Win32 API structs need to be
we have a C++ Win32 DLL that reads data from Excel. The application uses
I have an unmanaged Win32 C++ application that uses multiple C++ DLLs. The DLLs
I have searched a lot to find a solution for my problem, but I
I have a Windows server application, implemented in C++ using the Win32 API, that
I have a need to do some drawing using win32/GDI (Native, not .NET), and
I am trying to create an XML schema in which a lot of types

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.