与c编程有关 [英] related to c programming

查看:55
本文介绍了与c编程有关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

取消引用指向HW设备的内存映射地址空间的void指针会导致什么结果?

dereferencing a void pointer to a memory mapped address space of a HW device leads to what result?

推荐答案

首先,正如Emre Ataseven回答的那样,没有编译器可以取消引用一个无效*指针而不是演员。



对于你的问题,这实际上取决于架构,但在一般情况下,操作系统不会允许你因为内存映射的地址正好在内核的保护范围内 - 您需要使用API​​来访问这些位置。通常你不能取消引用不在你的进程内存中的任何内存位置。



当然如果你在内核模式或微控制器中工作,事情会有所不同,如任何地址都可以访问。
First and foremost, as Emre Ataseven answered, no compiler can dereference a void* pointer wothout a cast.

For your question it really depends on the architecture but in the general case the OS won't allow you taht because Memory Mapped addresses are right under the protective wing of the kernel - you need to use APIs to access to that locations. Normally you cannot dereference any memory location that isn't within your process memory.

Of course if you are working in kernel mode or in a microcontroller things are different, as any address is accessible.


这篇关于与c编程有关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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