Question: I have two applications written in C that include the same header. In this header I have the declaration of a struct. I use the GCC compiler to compile both applications.

When I execute both applications, they produce different values of `sizeof(struct-defined-in-the-header)`.

Why does this happen?

Answer: 
In my case it wasn't gcc and it was single application, but there were different results of sizeof(MyStruct) in different .c files.
The reason was in different packing values for structures, because those .c files had included different sets of .h files before including header with declaration of MyStruct.
The solution I adopted was to create general header with setting appropriate packing value and including it into all my .h files after system and library headers, but before my headers.
`sizeof` is **not** a function. It is a compile-time operator.

You don't tell what header is giving you trouble.

A possible guess might be that some obscure preprocessor trick is removing some field in it, or changing the real type of the field. For example, imagine that one header `foo.h` has

```
// in file foo.h 
#ifdef FOO_BAR
typedef short number_t;
#else
typedef long number_t;
#endif

```

and another header `bar.h` has

```
// in file bar.h
#define FOO_BAR
#include "foo.h"
struct barbare_st {
   number_t num;
   char name[20];
};

```

To find out, you could use the `ptype` command of the `gdb` debugger, or simply look into the preprocessed form `xxx.i` of some file `xxx.c` obtained with

```
gcc -C -E -Dappropriate_defines -Iinclude_dirs/ xxx.c > xxx.i

```