<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>External Array of Structure</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/30792/external-array-of-structure</link><description> 
Dear All, 
I am using LPC2138 with LCD display and key pad, program down loader
via URAT. 
I have program and big chunk of messages stored in Array of
Structure. Till now, I manage to compile whole thing and program and
system works fine. 
Now these</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: External Array of Structure</title><link>https://community.arm.com/thread/62253?ContentTypeID=1</link><pubDate>Mon, 16 Sep 2013 00:25:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:57717c81-f7fa-4476-99f0-b5bf4a927178</guid><dc:creator>Mahabir Prasad</dc:creator><description>&lt;p&gt;&lt;p&gt;
From Net, I able to find the solution, it works for structure to
defined in program but data are not part of program.&lt;br /&gt;
/* eemap.h */&lt;br /&gt;
struct CFG&lt;br /&gt;
{ char c; int i; long l; double d;};&lt;/p&gt;

&lt;p&gt;
struct CAL&lt;br /&gt;
{ int scale; int offset; int slope;};&lt;/p&gt;

&lt;p&gt;
struct LOG_ENTRY&lt;br /&gt;
{ long time; long meas;};&lt;/p&gt;

&lt;p&gt;
typedef struct EE_MAP&lt;br /&gt;
{ struct CFG cfg; struct CAL cal; struct LOG_ENTRY
log[1024];}EE_MAP;&lt;/p&gt;

&lt;p&gt;
#define EE_ADDR_CFG(mbr) (offsetof(EE_MAP, cfg) + offsetof(struct
CFG, mbr))&lt;br /&gt;
#define EE_ADDR_CAL(mbr) (offsetof(EE_MAP, cal) + offsetof(struct
CAL, mbr))&lt;br /&gt;
#define EE_ADDR_LOG() (offsetof(EE_MAP, log))&lt;br /&gt;
#define EE_ADDR_LOG_ENTRY(i) (EE_ADDR_LOG() + ((i) * sizeof(struct
LOG_ENTRY)))&lt;/p&gt;

&lt;p&gt;
Now to create the bin file to use, I have idea like this, which is
C++ program which have complete data and save them in bin file which
can be send to MCU on USB/UART to store in SPI flash or internal
flash which is not program. while using them, either it can be copied
in internal RAM or read in functions where it used directly.&lt;/p&gt;

&lt;p&gt;
#include &amp;lt;fstream.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;/p&gt;

&lt;p&gt;
struct EE_MAP EE_DATA =&lt;br /&gt;
{ // Init data as per need&lt;br /&gt;
} int main ( )&lt;br /&gt;
{ ofstream fout ; fout.open(&amp;quot;Saving&amp;quot;, ios :: out | ios :: binary) ;
// open output file if(!fout) { cout &amp;lt;&amp;lt; &amp;quot;File can&amp;#39;t be opened
\n&amp;quot; ; return 1; } fout.write((char *) &amp;amp; EE_DATA, sizeof(EE_MAP))
; // write to file fout.close() ; // close connection // read it back
now ifstream fin ; fin.open(&amp;quot;Saving&amp;quot;, ios :: out | ios :: binary) ;
// open input file fin.read((char *) &amp;amp; EE_DATA, sizeof(EE_MAP)) ;
// read structure fin.close( );&lt;br /&gt;
}&lt;/p&gt;

&lt;p&gt;
Any comments, please let me know or any better way. Just I am also
looking what will be overhead of padding for my application with
respect to without padding.&lt;/p&gt;

&lt;p&gt;
Regards&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>