<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>CodeWarrior Development ToolsのトピックRelocation without __declspec keyword</title>
    <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297880#M574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to program a bootloader-application combination at MPC5643L using CodeWarrior 10.5.&lt;/P&gt;&lt;P&gt;Bootloader and application communicate by a shared structure therefore the pointer to this structure must be located to a fixed address.&lt;/P&gt;&lt;P&gt;The access to the structure members via this pointer is located in various other files which are being shared with other projects so it's difficult to change the declaration of the variable.&lt;/P&gt;&lt;P&gt;So here's my question:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is it possible to locate a variable (in RAM) on a defined address without using the __declspec keyword ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;volatile tTableStruct TheTableStruct;&amp;nbsp; #pragma push #pragma section RW ".ptrTableStruct" volatile tTableStruct *TableStruct = &amp;amp;TheTableStruct; #pragma pop &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It compiles but the section ".ptrTableStruct" is empty and the pointer "TableStruct" is located somewhere in RAM.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I tried this:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;volatile tTableStruct TheTableStruct;&amp;nbsp; #pragma push #pragma section data_type ".ptrTableStruct" volatile tTableStruct *TableStruct = &amp;amp;TheTableStruct; #pragma pop &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P&gt;This leads to an linker error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sections used for data must have an uninitialized data section&lt;/STRONG&gt; in line #1&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Markus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Mar 2014 18:16:00 GMT</pubDate>
    <dc:creator>markusa</dc:creator>
    <dc:date>2014-03-17T18:16:00Z</dc:date>
    <item>
      <title>Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297880#M574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to program a bootloader-application combination at MPC5643L using CodeWarrior 10.5.&lt;/P&gt;&lt;P&gt;Bootloader and application communicate by a shared structure therefore the pointer to this structure must be located to a fixed address.&lt;/P&gt;&lt;P&gt;The access to the structure members via this pointer is located in various other files which are being shared with other projects so it's difficult to change the declaration of the variable.&lt;/P&gt;&lt;P&gt;So here's my question:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Is it possible to locate a variable (in RAM) on a defined address without using the __declspec keyword ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;volatile tTableStruct TheTableStruct;&amp;nbsp; #pragma push #pragma section RW ".ptrTableStruct" volatile tTableStruct *TableStruct = &amp;amp;TheTableStruct; #pragma pop &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It compiles but the section ".ptrTableStruct" is empty and the pointer "TableStruct" is located somewhere in RAM.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I tried this:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;volatile tTableStruct TheTableStruct;&amp;nbsp; #pragma push #pragma section data_type ".ptrTableStruct" volatile tTableStruct *TableStruct = &amp;amp;TheTableStruct; #pragma pop &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P&gt;This leads to an linker error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sections used for data must have an uninitialized data section&lt;/STRONG&gt; in line #1&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Markus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Mar 2014 18:16:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297880#M574</guid>
      <dc:creator>markusa</dc:creator>
      <dc:date>2014-03-17T18:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297881#M575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear markusa, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your post, however please consider moving it to the right community place (e.g. &lt;A href="https://community.nxp.com/space/2020"&gt;CodeWarrior Development Tools&lt;/A&gt; ) for better visibility.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For details please see general advice &lt;/SPAN&gt;&lt;A class="jive-link-wiki-small" data-containerid="2001" data-containertype="14" data-objectid="99909" data-objecttype="102" href="https://community.freescale.com/docs/DOC-99909"&gt;https://community.freescale.com/docs/DOC-99909&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for using Freescale Community.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Wlodek_D. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Mar 2014 10:23:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297881#M575</guid>
      <dc:creator>Wlodek_D_</dc:creator>
      <dc:date>2014-03-18T10:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297882#M576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Wlodek,&lt;/P&gt;&lt;P&gt;thank you for the information.&lt;/P&gt;&lt;P&gt;I've moved the post to the correct community place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Markus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Mar 2014 09:43:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297882#M576</guid>
      <dc:creator>markusa</dc:creator>
      <dc:date>2014-03-19T09:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297883#M577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello markusa,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The pragma section&amp;nbsp; requires also uninitialized section parameter to add&amp;nbsp; for&amp;nbsp; the&amp;nbsp; data sections.&lt;/P&gt;&lt;P&gt;If you have a small data threshold set to a default value which is 8 you should add also "sdata_type" parameter in order to place the pointer into your custom section.&lt;/P&gt;&lt;P&gt;Could you try to adjust the pragma section:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13954020747558657" jivemacro_uid="_13954020747558657" modifiedtitle="true"&gt;
&lt;P&gt;volatile tTableStruct TheTableStruct;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;#pragma push&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#pragma section data_type sdata_type ".ptrTableStruct" ".ptrTableStruct"&lt;/P&gt;
&lt;P&gt;volatile tTableStruct *TableStruct = &amp;amp;TheTableStruct;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;#pragma pop&amp;nbsp; &lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 11:49:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297883#M577</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2014-03-21T11:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297884#M578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Stanislav,&lt;/P&gt;&lt;P&gt;thank you - this solves the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you can help me with the 2nd issue too ...&lt;/P&gt;&lt;P&gt;The variable "TableStruct" is used in several (shared) files.&lt;/P&gt;&lt;P&gt;To access the variable I use the following code in each C-source file:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13954085342613011" jivemacro_uid="_13954085342613011"&gt;
&lt;P&gt;extern volatile tTableStruct* TableStruct;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But to be able to use these files with CW and other compilers I have to change it to:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13954085848055139" jivemacro_uid="_13954085848055139"&gt;
&lt;P&gt;#if defined(__COMPILER_CODEWARRIOR_ECLIPSE__)&lt;/P&gt;
&lt;P&gt;#pragma push&lt;/P&gt;
&lt;P&gt;#pragma section sdata_type ".ptrTableStruct" ".ptrTableStruct"&lt;/P&gt;
&lt;P&gt;extern volatile tTableStruct *TableStruct;&lt;/P&gt;
&lt;P&gt;#pragma pop&lt;/P&gt;
&lt;P&gt;#else&lt;/P&gt;
&lt;P&gt;extern volatile tTableStruct* TableStruct;&lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you think there is a better solution ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time,&lt;/P&gt;&lt;P&gt;Markus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 13:35:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297884#M578</guid>
      <dc:creator>markusa</dc:creator>
      <dc:date>2014-03-21T13:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297885#M579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Markus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there is an alternative way which does not require #pragma push/pop (so you can use a macro):&lt;/P&gt;&lt;P&gt;the "test.h" header file:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13956801297589631" jivemacro_uid="_13956801297589631"&gt;
&lt;P&gt;#pragma section RW ".ptrTableStruct" ".ptrTableStrct"&amp;nbsp; // defines a custom section to be used with __declspec(section ...)&lt;/P&gt;
&lt;P&gt;#define CW_DEF __declspec(section ".ptrTableStruct")&amp;nbsp;&amp;nbsp; // Create custom __declspec() macro&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12.222222328186035px;"&gt;#if __CWCC__&amp;nbsp;&amp;nbsp; // internal compiler macro to identify CodeWarrior Compiler &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="keyword" style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699; background-color: #f8f8f8;"&gt;CW_DEF extern&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f8f8f8;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699; background-color: #f8f8f8;"&gt;volatile&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f8f8f8;"&gt; tTableStruct *TableStruct;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f8f8f8;"&gt;#else&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;extern volatile&amp;nbsp; char* TableStruct;&lt;/P&gt;
&lt;P&gt;#endif&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a source file where table is defined:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_1395680129751843" jivemacro_uid="_1395680129751843"&gt;
&lt;P&gt;#include "test.h"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="keyword" style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699; background-color: #f8f8f8;"&gt;CW_DEF &lt;/SPAN&gt;&lt;SPAN class="keyword" style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #006699; background-color: #f8f8f8;"&gt;volatile&lt;/SPAN&gt;&lt;SPAN style="font-size: 12.222222328186035px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000; background-color: #f8f8f8;"&gt; tTableStruct *TableStruct;&lt;/SPAN&gt;&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Mar 2014 16:35:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297885#M579</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2014-03-24T16:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297886#M580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thx for the info.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Mar 2014 08:56:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297886#M580</guid>
      <dc:creator>markusa</dc:creator>
      <dc:date>2014-03-28T08:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297887#M581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On older versions of codewarrior it works like:&lt;/P&gt;&lt;P&gt;extern volatile &lt;SPAN&gt;tTableStruct&amp;nbsp; TableStruct @0xAAAAAAAA;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// where 0xAAAAAAAA is the addres you want your struct be placed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;volatile &lt;SPAN&gt;tTableStruct&amp;nbsp; TableStruct;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2018 10:00:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297887#M581</guid>
      <dc:creator>PedroBecerra</dc:creator>
      <dc:date>2018-04-27T10:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Relocation without __declspec keyword</title>
      <link>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297888#M582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pedro,&lt;/P&gt;&lt;P&gt;FYI: The "@" operator does not work in PowerPC version of compiler (CodeWarrior for MCUs).&lt;/P&gt;&lt;P&gt;It is applicable e.g. for S08, CFv1 targets.&lt;/P&gt;&lt;P&gt;Stan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2018 13:48:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-Development-Tools/Relocation-without-declspec-keyword/m-p/297888#M582</guid>
      <dc:creator>stanish</dc:creator>
      <dc:date>2018-04-27T13:48:45Z</dc:date>
    </item>
  </channel>
</rss>

