为什么此代码使用g ++而不是gcc进行编译?

编程入门 行业动态 更新时间:2024-10-07 22:24:12
本文介绍了为什么此代码使用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进行编译?

本文发布于:2023-11-29 15:43:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646834.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   代码   gcc

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!