什么是宏((无效(*)())0)()是什么意思? [英] What does the macro ((void(*)())0)() mean?

查看:199
本文介绍了什么是宏((无效(*)())0)()是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下宏的结果是显而易见的:

The outcome of the following macro is clear:

#define CRASH() do {\
  *(int *)(uintptr_t)0xbbadbeef = 0;\
  ((void(*)())0)();\
} while (false)

我的问题是,什么是行

My question is, what does the line

((void(*)())0)();

分解到,在英语吗?例如,这是返回一个指针....函数

break down to, in English? For example, "this is a function that returns a pointer to a...."

推荐答案

它看起来就像投下 0 作为函数指针(与签名,它需要没有参数,有返回void类型),然后调用它。

It looks like it casts 0 as a function pointer (with the signature that it takes not parameters and has void return type) and then invokes it.

(     (            void(*)()                  ) 0       )      ();
  /* cast..*/ /* fn pointer signature */  /*..cast 0 */  /* invocation */

这是另一种方式说,这是试图调用(呼叫),该公司预计将位于内存地址0x00000000功能 - 这是保证是一个无效的地址

Which is another way to say that it's trying to invoke (call) a function that's expected to be located in memory at address 0x00000000 - which is guaranteed to be an invalid address.

这篇关于什么是宏((无效(*)())0)()是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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