特定地址的数组 [英] Array at specific address

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

问题描述

嗨我有一系列无符号字符,例如:

MyArray [2048] = {0x00};


出于内存映射的目的,我需要将此数组存储在特定地址

(0xFFFF1199)


如何声明这个?


我不能做MyArray [2048] = {0x00} @ 0xFFFF1199 :-(


我正在使用gnu编译器。


Best问候

Don

Hi I have an array of unsigned chars, like:
MyArray[2048] = {0x00};

For memory-mapping purposes I need to store this array at a specific address
(0xFFFF1199)

How do I declare this?

I cant''t do MyArray[2048] = {0x00} @ 0xFFFF1199 :-(

I am using the gnu compiler.

Best Regards
Don

推荐答案

Don< no ** @ spam.dk>潦草地写道:
Don <no**@spam.dk> scribbled the following:
嗨我有一个无符号字符数组,如:
MyArray [2048] = {0x00};
出于内存映射的目的,我需要将此数组存储在特定地址
(0xFFFF1199)
如何申报?


你不能。不符合ISO标准C.在某些实施中,你不能
声明它。

我不能做MyArray [2048] = {0x00} @ 0xFFFF1199 :-(


否,你不能。

我正在使用gnu编译器。
Hi I have an array of unsigned chars, like:
MyArray[2048] = {0x00}; For memory-mapping purposes I need to store this array at a specific address
(0xFFFF1199) How do I declare this?
You can''t. Not under ISO standard C. On some implementations, you can''t
declare it at all.
I cant''t do MyArray[2048] = {0x00} @ 0xFFFF1199 :-(
No, you can''t.
I am using the gnu compiler.




它取决于你的编译器。由于安全原因,某些操作系统根本不允许b $ b允许特定地址。会发生什么

如果其他进程已经在使用该内存了吗?

请在gnu.gcc.help或系统特定的新闻组中询问。

-

/ - Joona Palaste(pa*****@cc.helsinki.fi)---------------- ----------- \

| 飞翔的柠檬树中的金鸡王G ++ FR FW + M-#108 D + ADA N +++ |

| http://www.helsinki.fi/~palaste W ++ B OP + |

\ -----------------------------------------芬兰的规则! ------------ /



It depends on more than your compiler. Some operating systems don''t
allow specific addresses at all, due to security reasons. What happens
if some other process is already using that memory?
Please ask in gnu.gcc.help or a system-specific newsgroup.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/


" Don" <无** @ spam.dk>写道:

#嗨我有一系列无符号字符,如:

#MyArray [2048] = {0x00};


如果它_has_是一个数组而不是(unsigned char *),许多链接器允许你指定外部对象的地址
。您可以尝试检查您的链接器

允许的内容。


-

Derk Gwen http://derkgwen.250free.com/html/index.html

你面向前方,或者你面临着震惊和伤害的可能性。
"Don" <no**@spam.dk> wrote:
# Hi I have an array of unsigned chars, like:
# MyArray[2048] = {0x00};

If it _has_ to be an array instead of (unsigned char*), many linkers allow you to
specify the address of extern objects. You might try checking what your linker
permits.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
You face forward, or you face the possibility of shock and damage.


Derk Gwen< de ****** @ hotpop.com>写道:
Derk Gwen <de******@hotpop.com> wrote:
" Don" <无** @ spam.dk>写道:
#嗨我有一系列无符号字符,如:
#MyArray [2048] = {0x00};

如果它_has_是一个数组而不是( unsigned char *),许多链接器允许您指定extern对象的地址。您可以尝试检查链接器允许的内容。
"Don" <no**@spam.dk> wrote:
# Hi I have an array of unsigned chars, like:
# MyArray[2048] = {0x00};

If it _has_ to be an array instead of (unsigned char*), many linkers allow you to
specify the address of extern objects. You might try checking what your linker
permits.




您也可以在没有链接器魔法的情况下执行此操作:


#define MyArray(*(volatile unsigned char(*)[2048])(0xdeadbeef))


- Kevin。



You can do it without linker magic also:

#define MyArray (*(volatile unsigned char (*)[2048])(0xdeadbeef))

- Kevin.

这篇关于特定地址的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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