I'm trying to compile grpc
, and one of the targets uses /usr/include/netinet/tcp.h
which contains this :
# if __BYTE_ORDER == __LITTLE_ENDIAN
uint8_t th_x2:4; /* (unused) */
uint8_t th_off:4; /* data offset */
# endif
# if __BYTE_ORDER == __BIG_ENDIAN
uint8_t th_off:4; /* data offset */
uint8_t th_x2:4; /* (unused) */
# endif
Somehow, the two conditions are fulfilled which makes the compilation fail (error: duplicate member 'th_off'
). I wrote a test C program and it seems that the three macros are not correctly defined.
I tried to reinstall gcc
and g++
, and also downgrade them to a previous version. I also tried to reinstall the Linux headers. I finally tried to compile with clang
, but it doesn't work either.
My two test computers are running Ubuntu 19.10 and the result is the same on both of them. Is there a compiler flag or a system configuration needed to define these macros?
EDIT : tcp.h
is a system header. I did not write it and it's an almost fresh install of Ubuntu with a standard installation of build-essentials
.
EDIT 2 : I used a test program and it works correctly in this case. It shows little
:
#include <iostream>
#include <netinet/tcp.h>
int main() {
#if __BYTE_ORDER == __LITTLE_ENDIAN
std::cout << "little\n";
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
std::cout << "big\n";
#endif
}