ç成语的名字 - '静态无效*的东西=安培;东西;` [英] Name of c idiom – `static void *thing = &thing;`

查看:78
本文介绍了ç成语的名字 - '静态无效*的东西=安培;东西;`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在code:

static const void *const uniquePtr = &uniquePtr;

...将提供一个独特的无效指针在编译单元。这是很方便的生成,像取了个名字为无效* 这样的API独特的手柄或名称。

…will provide a unique void pointer in the compilation unit. It's handy for generating a unique handle or name for APIs that like to take a name as a void* in this way.

使用的例子:

它会是明智的宏来包装这个模式来避免犯错它,而且封装的想法,使其自身的文件。

It'd be sensible to wrap this pattern in a macro to avoid making a mistake with it, and to encapsulate the idea so that it self documents.

但是,这导致了一个问题:是有这个成语,可用于命名宏的名称:

But that leads to the question: is there a name for this idiom that can be used to name the macro?:

#define DECLARE_VOID_THING(name) static const void *const name = &name
DECLARE_VOID_THING(aHandle);
DECLARE_VOID_THING(anotherHandle);

有什么想法?

推荐答案

正如散列出来上面有(极有可能)没有标准的说法,所以你可以自由选择任何你认为最好的。也许类似 UNIQUE_VOID_POINTER 或一些这样的。

As was hashed out above there is (very likely) no standard parlance, so you're free to choose whatever you think best. Perhaps something like UNIQUE_VOID_POINTER or some such.

这篇关于ç成语的名字 - '静态无效*的东西=安培;东西;`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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