__builtin_popcount(x) GCC提供的内建函数,主要作用是计算x表示成二进制时有多少个1(32位). 例如: int x = 7; // 7 = 111; int n = __builtin_popcount(x); //n = 3;