Fixed language linkage issue under clang-500.2.79

The declarations must be located before the respective friend
declaration to have a correct C language linkage.