Change pragma order in headers and fix gcc4.9 compiler warnings.