久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

extern inline 有什么作用?

What does extern inline do?(extern inline 有什么作用?)
本文介紹了extern inline 有什么作用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我了解 inline 本身是對編譯器的建議,它可以自行決定是否內聯函數,并且還會生成可鏈接的目標代碼.

I understand that inline by itself is a suggestion to the compiler, and at its discretion it may or may not inline the function, and it will also produce linkable object code.

我認為 static inline 做同樣的事情(可能會也可能不會內聯),但在內聯時不會產生可鏈接的目標代碼(因為沒有其他模塊可以鏈接到它).

I think that static inline does the same (may or may not inline) but will not produce linkable object code when inlined (since no other module could link to it).

extern inline 在哪里適合圖片?

假設我想用內聯函數替換預處理器宏并要求該函數被內聯(例如,因為它使用了 __FILE____LINE__ 宏,它們應該解析對于調用者,但不是這個被調用的函數).也就是說,如果函數沒有被內聯,我希望看到編譯器或鏈接器錯誤.extern inline 會這樣做嗎?(我假設,如果沒有,除了堅持使用宏之外,沒有辦法實現這種行為.)

Assume I want to replace a preprocessor macro by an inline function and require that this function gets inlined (e.g., because it uses the __FILE__ and __LINE__ macros which should resolve for the caller but not this called function). That is, I want to see a compiler or linker error in case the function does not get inlined. Does extern inline do this? (I assume that, if it does not, there is no way to achieve this behavior other than sticking with a macro.)

C++ 和 C 之間有區別嗎?

Are there differences between C++ and C?

不同的編譯器供應商和版本之間是否存在差異?

Are there differences between different compiler vendors and versions?

推薦答案

在 K&R C 或 C89 中,內聯不是語言的一部分.許多編譯器將其實現為擴展,但沒有關于它如何工作的定義語義.GCC 是最先實現內聯的,并引入了 inlinestatic inlineextern inline 結構;大多數 C99 之前的編譯器通常都跟隨它的步伐.

in K&R C or C89, inline was not part of the language. Many compilers implemented it as an extension, but there were no defined semantics regarding how it worked. GCC was among the first to implement inlining, and introduced the inline, static inline, and extern inline constructs; most pre-C99 compiler generally follow its lead.

  • inline:函數可以被內聯(不過這只是一個提示).外部版本總是發出并且外部可見.因此,您只能在一個編譯單元中定義這樣的內聯,而其他每個編譯單元都需要將其視為外聯函數(否則您將在鏈接時得到重復的符號).
  • extern inline 不會生成外聯版本,但可能會調用一個(因此您必須在其他某個編譯單元中定義它.不過,一個定義規則適用;out-of-line 版本必須具有與此處提供的內聯相同的代碼,以防編譯器調用它.
  • static inline 不會生成外部可見的外聯版本,盡管它可能會生成文件靜態版本.單一定義規則不適用,因為從來沒有發出過外部符號,也沒有調用過.
  • inline: the function may be inlined (it's just a hint though). An out-of-line version is always emitted and externally visible. Hence you can only have such an inline defined in one compilation unit, and every other one needs to see it as an out-of-line function (or you'll get duplicate symbols at link time).
  • extern inline will not generate an out-of-line version, but might call one (which you therefore must define in some other compilation unit. The one-definition rule applies, though; the out-of-line version must have the same code as the inline offered here, in case the compiler calls that instead.
  • static inline will not generate a externally visible out-of-line version, though it might generate a file static one. The one-definition rule does not apply, since there is never an emitted external symbol nor a call to one.
  • inline:像GNU89extern inline";不發出任何外部可見的函數,但可能會被調用,因此必須存在
  • extern inline:像GNU89內聯":發出外部可見的代碼,所以最多一個翻譯單元可以使用它.
  • static inline:類似于 GNU89 的靜態內聯".這是 gnu89 和 c99 之間唯一可移植的
  • inline: like GNU89 "extern inline"; no externally visible function is emitted, but one might be called and so must exist
  • extern inline: like GNU89 "inline": externally visible code is emitted, so at most one translation unit can use this.
  • static inline: like GNU89 "static inline". This is the only portable one between gnu89 and c99

在任何地方內聯的函數必須在任何地方內聯,具有相同的定義.編譯器/鏈接器將整理出符號的多個實例.static inlineextern inline 沒有定義,盡管許多編譯器都有它們(通常遵循 gnu89 模型).

A function that is inline anywhere must be inline everywhere, with the same definition. The compiler/linker will sort out multiple instances of the symbol. There is no definition of static inline or extern inline, though many compilers have them (typically following the gnu89 model).

這篇關于extern inline 有什么作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉換為 HSV 并將 HSV 轉換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉換為字符串?)
When to use inline function and when not to use it?(什么時候使用內聯函數,什么時候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關嗎?)
主站蜘蛛池模板: 国产成人久久精品 | 夜夜骑av | 国产精品欧美精品 | 欧美激情在线一区二区三区 | 精品欧美激情在线观看 | 亚洲一区 | www精品美女久久久tv | 一区二区三区免费 | 国产精品theporn| 国产99精品 | 中文字幕在线观看一区二区 | 一级在线视频 | 久久精品欧美一区二区三区不卡 | 99精品视频在线观看 | 欧美不卡视频一区发布 | 国产91综合 | 蜜臀网| 夜操| av高清| 91porn国产成人福利 | 999免费观看视频 | 日韩淫片免费看 | 99爱在线免费观看 | 一区二区三区四区免费在线观看 | 亚洲免费婷婷 | 天堂va在线观看 | 亚洲精品白浆高清久久久久久 | 中文字幕精品一区久久久久 | 一级全黄少妇性色生活免费看 | 欧美电影免费观看 | 色偷偷噜噜噜亚洲男人 | 日韩欧美在线播放 | 在线亚洲欧美 | 精品国产欧美一区二区三区成人 | 久久久久久久久久影视 | 黄a在线观看 | 亚洲精品视频在线观看视频 | 亚洲情综合五月天 | 精品videossex高潮汇编 | 欧美激情精品久久久久久免费 | 精品自拍视频 |