<?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>Import definitions/macros</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/28999/import-definitions-macros</link><description> 
Hello... 

 
Currently I am using a header file that contains imported
variables/functions/arrays at specific addressing. This is not ideal
but it is the only workaround I have for my project. Now I&amp;#39;m trying
to modularize my code therefore I am not</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/130973?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2012 08:22:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0744cd7c-98ca-42d0-83aa-3025be1a04a9</guid><dc:creator>Shayan Farsi</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for the info and link.&lt;/p&gt;

&lt;p&gt;
Cheers&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/127399?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2012 16:31:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b10acec7-09d5-447d-a23b-bb861e86e6fa</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;a href="http://www.keil.com/forum/search.asp?SA=8051&amp;amp;KW=&amp;amp;DY=&amp;amp;PL=&amp;amp;Q=function+pointer&amp;amp;KB=ON&amp;amp;AN=ON&amp;amp;PM=ON&amp;amp;PG=1&amp;amp;PX=1&amp;amp;AV=ON"&gt;
&lt;a href="http://www.keil.com/forum/search.asp?SA=8051&amp;amp;KW=&amp;amp;DY=&amp;amp;PL=&amp;amp;Q=function+pointer&amp;amp;KB=ON&amp;amp;AN=ON&amp;amp;PM=ON&amp;amp;PG=1&amp;amp;PX=1&amp;amp;AV=ON"&gt;www.keil.com/.../search.asp&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/119636?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2012 10:40:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c2f3eb03-2d44-490f-a051-9cc10ccd0540</guid><dc:creator>doubt that my ISP Al Bradford</dc:creator><description>&lt;p&gt;&lt;p&gt;
We agree with the posts warning you of the indirect addressing
problems of the 8051. Look at the PK51 Linker Manual and pay close
attention to the &lt;b&gt;OVERLAY&lt;/b&gt; directives and their examples.&lt;/p&gt;

&lt;p&gt;
Bradford&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/105809?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2012 09:43:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5479788f-2f4a-43d1-94c2-60f8b9c4e2d7</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Take a closer look at the instruction set of the processor, and
you would see that the processor does not have any great _general_
instructions for indurect addressing.&lt;/p&gt;

&lt;p&gt;
That also affects the ability to use a _real_ stack with indirect
addressing of parameters and local variables relative to a base
pointer. Which makes the C51 compiler convert parameters and local
variables into reused global variables. And that optimization requirs
the compiler/linker to know exactly what functions that can call
other functions - how else would the compiler/linker know which two
different local variables that can share the same global memory
address?&lt;/p&gt;

&lt;p&gt;
The 8051 architecture is extremely hostile for use with high-level
languages.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/116733?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2012 09:26:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9e54d26e-2ff8-4bfd-9778-072fd7187a44</guid><dc:creator>Bored Over Christmas</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Wresting then into the architecture&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Come on smartie pants. How about some detail?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/105812?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2012 08:51:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8cb5d2c4-c880-45e8-92ae-f1437a5ddf4f</guid><dc:creator>Tamiryan Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Wresting then into the architecture :-)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/80070?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2012 07:23:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:dc2b6166-a3d5-4d49-9bf0-b52dcc8ef4d2</guid><dc:creator>Shayan Farsi</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;... and function pointers have some serious issues in
C51...&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Thanks for the tip. I have heard about this issue and will keep an
eye out for it. Just out of curiosity what is the cause of the
issue?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/67308?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2012 15:05:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3637f176-ad23-402a-82d8-3b1ce4035017</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
... and &lt;b&gt;function pointers&lt;/b&gt; have some serious issues in
C51...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/105808?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2012 14:07:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:aedc5f06-ce91-422a-9ebb-c706134b63ef</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Then whoever is responsible for that export should be shot!&lt;/p&gt;

&lt;p&gt;
As already noted, doing it in your own project is bad enough - but
exporting it to anyone else&amp;#39;s project is unforgivable!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/80073?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2012 12:44:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2fb2a6fb-35ba-48d7-91ed-bca5678a0630</guid><dc:creator>Shayan Farsi</dc:creator><description>&lt;p&gt;&lt;p&gt;
As I mentioned this was just rough code to make my point. This is
in no way the actual code or the absolute addresses used.&lt;/p&gt;

&lt;p&gt;
I understand where externs should be used. The header mentioned is
exported from another project so I cannot directly make changes to
it. I was just trying to work around what I was dealt with, and after
reading your comments I have made requests for changes in the other
project. Thanks for your time.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/80071?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2012 12:39:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2ddd530b-5730-4460-9154-2560ff263d6f</guid><dc:creator>Shayan Farsi</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks Andrew. The problem was that the header is being created
and exported from another project and it is certainly not the ideal,
or honestly proper way of coding. I am aware of the difference
between definitions and declarations, and where they should be
located.&lt;/p&gt;

&lt;p&gt;
Sometimes you have to work with what you are dealt with. I have
put in the request for the necessary changes... I was simply
wondering if there is work around. Thanks for your time.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/60487?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2012 12:17:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8932677e-738c-42e6-980b-217cc1eb578a</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;pre&gt;
&lt;i&gt;volatile int flags _at_ 0;&lt;/i&gt;
&lt;/pre&gt;

&lt;p&gt;
Goodness. If there ever was a position where you should &lt;b&gt;not&lt;/b&gt;
put an absolute-address object on a &amp;#39;51 CPU, that one&amp;#39;s it. You&amp;#39;ve
just usurped the memory location of R0.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;Now I&amp;#39;m trying to modularize my code therefore I am not able to
include this header file in all modules as it will cause linker
errors. I am using extern to get around that for var
declarations.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
You got that bass-ackwards. The whole problem is that you&amp;#39;re using
extern in the wrong place.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;I was wondering if there is any way to import #define &amp;#39;s other
than simply copying them over to each module.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
You already found that way: put them into #include files. That&amp;#39;s
what they&amp;#39;re for.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Import definitions/macros</title><link>https://community.arm.com/thread/67307?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2012 11:01:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c78b9b97-a690-404e-9cf2-5f5971525223</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
What, exactly, are you &amp;quot;working around&amp;quot; ?!&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;I am not able to include this header file in all modules as it
will cause linker errors&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That&amp;#39;s exactly why you should &lt;i&gt;&lt;b&gt;not&lt;/b&gt;&lt;/i&gt; have definitions
in header files!&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://c-faq.com/decl/decldef.html"&gt;c-faq.com/.../decldef.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;I will loose the modularization because of the specific
addressing&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
So why have it in a header file?&lt;/p&gt;

&lt;p&gt;
The &lt;i&gt;&lt;b&gt;definition&lt;/b&gt;&lt;/i&gt; (which includes the absoltue
addressing) should be in a &lt;b&gt;.c&lt;/b&gt; file; only the &lt;b&gt;extern
&lt;i&gt;declaration&lt;/i&gt;&lt;/b&gt; should be in the header.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>