在什么机器可以(*(无效(*)())0)()一起使用? [英] In what machine can (* (void (*)()) 0)() be used?

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

问题描述

C陷阱与缺陷2.1
我以为0总是无效的地址。他怎么能在那个位置把一个函数?

C traps and pitfalls 2.1 I thought 0 is always invalid address. How could he put a function in that position?

推荐答案

这是体系结构相关。

从书:


一旦
交谈

有人


写作
一个
C
程序





单机

一个

微处理器(答案就在这里)。
什么时候
这个


交换的
上,

硬件

呼叫

子程序
谁的
地址

存储

位置
0。

订购

模拟
车削
功率
上,
我们


设计
一个
C
声明


呼叫
这个
子程序
明确。

一些
思想,
我们
来了
向上


以下内容:

I once talked to someone who was writing a C program that was going to run stand-alone in a small microprocessor (answer right here). When this machine was switched on, the hardware would call the subroutine whose address was stored in location 0. In order to simulate turning power on, we had to devise a C statement that would call this subroutine explicitly. After some thought, we came up with the following:

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

这篇关于在什么机器可以(*(无效(*)())0)()一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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