move typedefs so they are not redefined

this is allowed in C11, but not in C89 or C99, and older
versions of GCC don't accept this.