Can the size of a structure change after compiled?

Posted by Sarah Altiva on Stack Overflow See other posts from Stack Overflow or by Sarah Altiva
Published on 2010-04-09T12:34:42Z Indexed on 2010/04/09 12:43 UTC
Read the original article Hit count: 196

Filed under:
|

Hi, 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 in my machine (32-bit OS) the output is the following:

Structure size: 148, BOOL size: 4.

I would like to know if, once compiled, these values may change depending on the machine which runs the program. E.g.: if I ran this program in a 64-bit machine, would the output be the same? Or once it's compiled it'll always be the same?

Thank you very much, and forgive me if the answer to this question is obvious...

© Stack Overflow or respective owner

Related posts about c

    Related posts about sizeof