CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2019
    Posts
    59

    DWORD size in VS

    in visual studio when moving mouse over a DWORD variable, it shows 5 bytes. I expected to see 4 bytes. Not sure why i see extra byte there?. sizeof(DWORD) shows 4 bytes. this happens in x64 , do not remember if looked at it in 32 bit mode as well?.

  2. #2
    Join Date
    Feb 2017
    Posts
    674

    Re: DWORD size in VS

    Quote Originally Posted by @EE@ View Post
    a DWORD variable, it shows 5 bytes
    Maybe the variable is a DWORD array. In that case, the 5 you see could denote the array size (rather than the DWORD size.)

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,301

    Re: DWORD size in VS

    Quote Originally Posted by @EE@ View Post
    in visual studio when moving mouse over a DWORD variable, it shows 5 bytes. I expected to see 4 bytes. Not sure why i see extra byte there?. sizeof(DWORD) shows 4 bytes. this happens in x64 , do not remember if looked at it in 32 bit mode as well?.
    Where do you see the DWOORD size?
    Attachment 36057
    Attachment 36058
    I don't see any size info here. VS 2022 17.2.6. It is shown the same info for both x86 and x64
    Victor Nijegorodov

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,692

    Re: DWORD size in VS

    DWORD is unsigned 32-bit - irrespective of 32/64 bit. When you hover the mouse over a DWORD type, intellisense shows a typedef (as per Victor's 36058 above).

    If you're seeing a number when hovering over a variable, then that is an array and you're seeing the array size.

    Post your code so that we can see what's going on.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.4.2)

  5. #5
    Join Date
    Aug 2019
    Posts
    59

    Re: DWORD size in VS

    DWORD dw;
    dw = CalcAvgOfArray(...)
    when I move mouse over the dw in debug mode i see dw like 3465238465. this is 5 bytes not 4 bytes.
    cout << sizeof(DWORD); shows 4.
    can't open Victor's attachments.
    Last edited by @EE@; August 21st, 2022 at 09:31 PM.

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,692

    Re: DWORD size in VS

    3465238465 is 0xCE8B57C1 which is 4 bytes - 32 bits!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.4.2)

  7. #7
    Join Date
    Aug 2019
    Posts
    59

    Re: DWORD size in VS

    missed that.
    thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured