简体   繁体   English

在指定位置声明变量/数组?

[英]Declaring a variable/array in the specified location?

My aim is to port a #pragma define_section code to something that works on the GCC compiler( I have found out that some of the #pragma directives don't work on GCC compilers. Of course, my findings may be wrong.)我的目标是将#pragma define_section 代码移植到在 GCC 编译器上工作的东西(我发现一些#pragma 指令在 GCC 编译器上不起作用。当然,我的发现可能是错误的。)

#pragma define_section appheader_info ".appheader_info"  far_absolute R
__declspec(appheader_info) FLASH_APPHEADER_INFO appheader_info =

This is what I need to change to something to work on GCC.这是我需要更改为在 GCC 上工作的内容。 Basically, I need to declare a variable/array in a specific location.基本上,我需要在特定位置声明一个变量/数组。

extern uint8_t dev_serial[12];
  asm(".equ dev_serial, 0x1FFFF7E8");

This is what I tried as an alternate to declare an array in the specified location ie, 0x1FFFF7E8.这就是我尝试在指定位置(即 0x1FFFF7E8)声明数组的替代方法。 I've tried printing the address of the array, and it is located in the given variable.我试过打印数组的地址,它位于给定的变量中。 But I could not define values to the array.但我无法为数组定义值。 It always shows zero.它总是显示为零。

How do I overcome this issue and is there any alternative solution to achieve my aim?我该如何克服这个问题,是否有任何替代解决方案来实现我的目标?

Btw I'm trying this in both the STM32 development board and S32K144 series microcontroller.顺便说一句,我正在 STM32 开发板和 S32K144 系列微控制器中尝试这个。

Thank you in advance.先感谢您。

This is the alternative I found instead of using the #pragma directives.这是我找到的替代方法,而不是使用 #pragma 指令。

__attribute__ ((section(".appheader_info"))) FLASH_APPHEADER_INFO appheader_info;

but I still haven't figured out how to define values for the variable.但我还没有弄清楚如何定义变量的值。

Still hoping somebody can help me with this.仍然希望有人可以帮助我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM