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: 
First of all, make sure to do a clean build of everything.

If the problem persists, this could mean that different compilation options have been used for the two translation units. I would capture the `gcc` command lines used for the two compilations, and would compare them, paying particular attention to any options having to do with alignment, structure padding etc.

Another possibility is that the definition of the struct depends on some preprocessor symbols, and the symbols get defined differently for the two translation units. Using `gcc -E` and comparing the struct definition in the two preprocessor outputs would be a good start.
`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

```