Objective-C中的static,extern和inline [英] Static, extern and inline in Objective-C

查看:112
本文介绍了Objective-C中的static,extern和inline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用LLVM编译器在Objetive-C中staticexterninline(及其组合)是什么意思?

What do static, extern and inline (and their combinations) mean in Objetive-C using the LLVM compiler?

此外,我注意到有CG_EXTERNCG_INLINE宏.我们应该改用那些吗?

Also, I noticed that there are CG_EXTERN and CG_INLINE macros. Should we be using those instead?

(我找不到明确说明的资源,因此我认为在此处创建一个源可能有用,或者如果有人知道一个源,则指向它)

推荐答案

使用LLVM编译器在Objetive-C中,static,extern和inline(及其组合)是什么意思?

What do static, extern and inline (and their combinations) mean in Objetive-C using the LLVM compiler?

与C中的相同,除非您以ObjC ++的形式进行编译-否则它们的含义与C ++中的相同.

The same as in C, unless you compile as ObjC++ -- then they mean the same as found in C++.

所以这里是C的简介,但是如果您准备使用这些链接,则请阅读这些链接,因为这些细节很重要:

So here is an introduction for C, but read the links if you are ready to use these because the details are important:

外部

摘要:表示在其他地方定义了一个标识符.

详细信息: http://tigcc.ticalc.org/doc/keywords.html#外部

静态

摘要(值):保留变量值以使其作用域结束后仍然存在.

摘要(函数):有效地发出未命名的副本-对于C语言中的私有函数很有用,当与内联函数一起使用时,可用于避免多个定义错误.

Summary (function): Effectively emits unnamed copies - useful for private functions in C, and can be used to escape multiple definition errors when used with inline functions.

详细信息: http://tigcc.ticalc.org/doc/keywords.html#静态

内联

摘要:建议将函数主体移入调用方中.

Summary: Suggests the body of a function should be moved into the callers.

详细信息: http://tigcc.ticalc.org/doc/gnuexts.html# SEC93

请注意,内联和静态在C ++中要复杂得多(类似于C ++中的几乎所有内容).

Note that inline and static are quite a bit more complex in C++ (like pretty much everything in C++).

我还发现有CG_EXTERN和CG_INLINE宏.我们应该改用那些吗?

I also found that there are CG_EXTERN and CG_INLINE macros. Should we be using those instead?

否.

相反,如果需要这种功能,则应使用自己的意思指定自己的名称. CG_EXTERNCG_INLINE具有特定含义(可能会发生变化),并且打算在其定义的上下文中使用-而且,您也不想包含一整套框架(所有CoreGraphics/ApplicationServices/要在C和C ++中使用某种方式指定extern,则需要指定CoreFoundation等.

Instead, you should specify your own, with your own meanings, if you need this type of functionality. CG_EXTERN and CG_INLINE have specific meanings (which may change), and are meant to be used in their defined context -- also, you don't want to have to include a whole handful of frameworks (all CoreGraphics/ApplicationServices/CoreFoundation/etc.) when you want to specify something is extern in a way that works in C and C++.

这篇关于Objective-C中的static,extern和inline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆