热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

内联vs内联vs内联vs内联?-inlinevs__inlinevs__inline__vs__forceinline?

Whatarethedifferencesbetweenthesefourinline(key)words?这四个内联(关键字)的区别是什么?inline,__inline,

What are the differences between these four inline (key)words?

这四个内联(关键字)的区别是什么?

inline, __inline, __inline__, __forceinline.

内联、__inline __inline__ __forceinline。

3 个解决方案

#1


75  

inline is the keyword, in C++ and C99.

inline是关键字,在c++和C99中。

__inline is a vendor-specific keyword (e.g. MSVC) for inline function in C, since C89 doesn't have it.

__inline是C中的一个特定于供应商的关键字(例如MSVC),因为C89没有内联函数。

__inline__ is similar to __inline but is from another set of compilers.

__inline__类似于__inline,但来自另一组编译器。

__forceinline is another vendor-specific (mainly MSVC) keyword, which will apply more force to inline the function than the __inline hint (e.g. inline even if it result in worse code).

__forceinline是另一个特定于供应商(主要是MSVC)的关键字,它将对内联函数施加比__inline暗示更大的压力(例如,即使内联导致更糟糕的代码)。

There's also __attribute__((always_inline)) in GCC and clang.

在GCC和clang中也有__attribute__((always_inline))。

#2


18  

__inline, __inline__ and __forceinline are all implementation specific. Because of the double underscore they are all identifiers reserved for the implementation so shouldn't conflict with identifiers used in applications.

__inline、__inline__和__forceinline都是特定于实现的。由于双下划线,它们都是为实现保留的标识符,因此不应与应用程序中使用的标识符冲突。

inline is the only C++ keyword.

内联是唯一的c++关键字。

#3


8  

For the Visual Studio compiler it means:

对于Visual Studio编译器,它的意思是:

  • inline - suggestion to the compiler to inline your code

    内联—建议编译器内联您的代码

  • __forceinline - overrides the builtin compiler optimization and generates inline code

    __forceinline -重写构建编译器优化并生成内联代码

For more details see: http://msdn.microsoft.com/en-us/library/z8y1yy88%28VS.71%29.aspx

详情请参阅:http://msdn.microsoft.com/en- us/library/z8y1y1y88%28vs.71%29.aspx


推荐阅读
author-avatar
372630243
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有