The problem is that the include file "interfaces/jpeg.h" doesn't include "jpeg/jpeg.h", so when gcc first encounters struct JPEGDecHandle in a function definition there it creates an implicit local definition. That's why later when it encounters the JPEGDecHandle in "jpeg/jpeg.h" it thinks it's a different structure.

This is also why you should always check the first warning/error first when compiling C code because it will often explain later ones and when you fix it they will be fixed too.

In this case gcc reported this error:

In file included from ../../include/proto/jpeg.h:31:0,

from main.c:20:

../../include/interfaces/jpeg.h:28:71: error: ‘struct JPEGDecHandle’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror]