tags:

views:

65

answers:

2

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...

+2  A: 

It is fixed and will not change once compiled. On a 64-bit machine, it will still run as a 32-bit application.

Mark Wilkins
Yeap, this is called 32-bit emulation mode. Either you have it or your native code program will not run.
sharptooth
Thank you very much, I'm just starting to code in C and didn't know how would this be.
Sarah Altiva
+2  A: 

They won't change, unless Chuck Norris says so.

jweyrich