@hwnd%

Discussions related to graphics (2D and 3D), animation and games programming
Richard Russell
Posts: 677
Joined: Tue 18 Jun 2024, 09:32

Re: @hwnd%

Post by Richard Russell »

Richard Russell wrote: Thu 23 Apr 2026, 13:15 (these are 32-bits values, not 64):
Compiled for 64-bits:

sizeof(D3D11_DEPTH_STENCIL_DESC) = 52
sizeof(D3D11_DEPTH_STENCIL_VIEW_DESC) = 24

Confirming that they are indeed unchanged in size from 32-bits.
User avatar
JeremyNicoll
Posts: 92
Joined: Sun 26 Jul 2020, 22:22
Location: Edinburgh

Re: @hwnd%

Post by JeremyNicoll »

Richard Russell wrote: Thu 23 Apr 2026, 13:01
I commonly check the sizes of structures by compiling them. You don't need entire SDKs or IDEs for that, just the relevant header (.h) file which can usually be found at GitHub. Here's an extract from the output from just such a program of mine:
...
sizeof(WSADATA) = 400
sizeof(DXGI_SWAP_CHAIN_DESC) = 60

The only reason I thought of VS CE is that some of the StackOverflow posts I read seemed to imply that it comes with many/most/some sets of standard header files & would presumably install itself already knowing where those were & might be able to compile something with minimal subsequent setup.

Which compiler are you using for this? Do you just run it from the CLI?

Can one tell from a header file what the length of different data-types (for a specific architecture) is & what the alignment rules are?
Richard Russell
Posts: 677
Joined: Tue 18 Jun 2024, 09:32

Re: @hwnd%

Post by Richard Russell »

JeremyNicoll wrote: Thu 23 Apr 2026, 15:41 The only reason I thought of VS CE is that some of the StackOverflow posts I read seemed to imply that it comes with many/most/some sets of standard header files...
That's true, but it's a massive install and I would have concerns about it interfering with existing development tools (e.g. C compilers and linkers) if utilities or files with the same name were to be added to the PATH by that installation. Anybody developing Windows applications will already have all the relevant header files (in my case installed automatically by MinGW).
Which compiler are you using for this? Do you just run it from the CLI?
GCC, it's by far the most popular non-proprietary (i.e. non-Microsoft and non-Intel) compiler (I know there's Clang, but as discussed in a recent thread here that lacks the global register variables feature which is so valuable to an interpreter). :D
Can one tell from a header file what the length of different data-types (for a specific architecture) is & what the alignment rules are?
Not typically, no, because everything will relate back to the native C data types like char and int and only the compiler knows what their sizes are on any given platform and configuration.

Even if you can deduce the size from header files alone, doing this 'manually' is a nightmare because it can involve tracing through a hierarchy of dozens of dependent header files. Letting the compiler do it for you is much easier and safer!