Why does this code compile with g++ but not gcc?
问题 The following piece of code compiles with g++ and not gcc, and am stuck wondering why? inline unsigned FloatFlip(unsigned f) { unsigned mask = -int(f >> 31) | 0x80000000; return f ^ mask; } I would assume that in C++, int(f >> 31) is a constructor but that leaves me wondering why it's included in the code. Is it necessary? 回答1: C doesn't support the C++ "function-style" casting. You need to write it like this unsigned mask = -(int)(f >> 31) | 0x80000000; See cast operator 回答2: You can use C