Forum Discussion
Altera_Forum
Honored Contributor
19 years agostruct
The following code works fine:
# define RAMSHADOWBASE 0x01010000# define TESTVARIABLE (*(unsigned int*)RAMSHADOWBASE) Now I want to add a struct on the same way. Thus I want to place a structure on a predefined adress in RAM memory. Struct looks like: struct Defs { unsigned int Nr; unsigned int Place; } lacingHole[40]; Somebody a solution for this?2 Replies
- Altera_Forum
Honored Contributor
Nobody a solution????
--- Quote Start --- originally posted by innotronics@Jan 9 2007, 10:40 AM the following code works fine:# define ramshadowbase 0x01010000# define testvariable (*(unsigned int*)ramshadowbase)
now i want to add a struct on the same way. thus i want to place a structure on a predefined adress in ram memory.
struct looks like:
struct defs
{
unsigned int nr;
unsigned int place;
} lacinghole[40];
somebody a solution for this?
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=20433)
--- quote end ---
--- Quote End ---
- Altera_Forum
Honored Contributor
Hi innotronics,
There are two common ways of accomplishing what (I believe) you want: 1, access the structure via a pointer:
or ...#define DEFSBASE 0x01010000 struct Defs *pDefs = (struct Defs *) DEFSBASE; ... pDefs->Nr = <<whatever>>2. put the structure in a named section ...
... then locate the section where you want in your linker command file.struct Defs myDefs __attribute__ ((section (",defs"))); myDefs.Nr = <<whatever>>
Regards, --Scott__defs_start = .; .defs : { *(.defs) }