<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/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/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Flash Data Storage - initializer element is not constan</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/22757/flash-data-storage---initializer-element-is-not-constan</link><description>Hi, 
 i am trying to save data with the flash data storage module. Using this code ( infocenter.nordicsemi.com/index.jsp from infocenter erverything works fine. But when i want to store my own value i get an &amp;quot;initializer element is not constant&amp;quot; error</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Jun 2017 08:42:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/22757/flash-data-storage---initializer-element-is-not-constan" /><item><title>RE: Flash Data Storage - initializer element is not constan</title><link>https://devzone.nordicsemi.com/thread/89463?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2017 08:42:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bd65687-f444-47b6-9b1b-40abf0a3fc83</guid><dc:creator>emdi</dc:creator><description>&lt;p&gt;When a variable is declared as constant in C, it has to be initialized at compile time.
This means that the compiler has to be able to know the value you are assigning to the variable.
However, you are attempting to a assign the value of a variable, which is not known at compile time. Thus, you receive an error during compilation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Data Storage - initializer element is not constan</title><link>https://devzone.nordicsemi.com/thread/89467?ContentTypeID=1</link><pubDate>Wed, 14 Jun 2017 16:02:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41760316-96dc-4f82-9396-4dc4b12fe963</guid><dc:creator>trice8</dc:creator><description>&lt;p&gt;That worked fine. Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Data Storage - initializer element is not constan</title><link>https://devzone.nordicsemi.com/thread/89466?ContentTypeID=1</link><pubDate>Wed, 14 Jun 2017 13:32:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d740ffce-4d98-4689-916f-9b60b4fc997b</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;I have updated my answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Data Storage - initializer element is not constan</title><link>https://devzone.nordicsemi.com/thread/89465?ContentTypeID=1</link><pubDate>Wed, 14 Jun 2017 12:58:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58471264-f61e-4b39-8568-65e84dfe87f0</guid><dc:creator>trice8</dc:creator><description>&lt;p&gt;It&amp;#39;s defined as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t my_own_data;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in my .c file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Flash Data Storage - initializer element is not constan</title><link>https://devzone.nordicsemi.com/thread/89464?ContentTypeID=1</link><pubDate>Wed, 14 Jun 2017 11:15:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcff8b4e-a140-45e6-acdf-8bb746b61180</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;How is &lt;code&gt;my_own_data&lt;/code&gt; defined?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; When writing data, it is record_chunk.p_data that needs the data. The easiest is to assign &lt;code&gt;my_own_data&lt;/code&gt; directly to &lt;code&gt;p_data&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;record_chunk.p_data         = &amp;amp;my_own_data;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>