Can the size of the structure change after compilation?

Suppose you have the following structure:

#include <windows.h> // BOOL is here. #include <stdio.h> typedef struct { BOOL someBool; char someCharArray[100]; int someIntValue; BOOL moreBools, anotherOne, yetAgain; char someOthercharArray[23]; int otherInt; } Test; int main(void) { printf("Structure size: %d, BOOL size: %d.\n", sizeof(Test), sizeof(BOOL)); } 

When I compile this piece of code on my computer (32-bit OS), the output is as follows:

 Structure size: 148, BOOL size: 4. 

I would like to know if these values ​​after compilation may change depending on the machine that runs the program. For example: if I run this program on a 64-bit machine, will the output be the same? Or once it is compiled, will it always be the same?

Thank you, and I'm sorry if the answer to this question is obvious ...

+4
source share
2 answers

It is committed and will not change after compilation. On a 64-bit machine, it will still work as a 32-bit application.

+5
source

They won't change if Chuck Norris doesn't say that.

+2
source

Source: https://habr.com/ru/post/1306473/


All Articles