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.
I use Eclipse to compile the programs. I checked flags of compilation. Look:

```
    gcc -I/lib-header-directory-with-struct -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"program-a.d" -MT"program-a.d" -o"program-a.o" "../program-a.c"

    gcc -I/lib-header-directory-with-struct -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"program-b.d" -MT"program-b.d" -o"program-b.o" "../program-b.c"
    gcc -L/lib-directory-with-struct -o"program-b" -l<lib-with-struct>

```

The difference between them is that in one I used the lib and in another I used struct definition only.

I used `gcc -E` and redirect stdout to file. I looked for struct definition in this file and it is the same in both programs.