本文介绍了为什么此代码使用g ++而不是gcc进行编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码使用g ++而不是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; }我认为在C ++中,
int(f >> 31)是一个构造函数,但是让我想知道为什么它包含在代码中。
is a constructor but that leaves me wondering why it's included in the code. Is it necessary?
推荐答案C不支持 C ++函数式强制转换。您需要这样写:
C doesn't support the C++ "function-style" casting. You need to write it like this
unsigned mask = -(int)(f >> 31) | 0x80000000;请参见广播运算符
更多推荐
为什么此代码使用g ++而不是gcc进行编译?
发布评论