<?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>How to conditionally NOAREG a fn?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31561/how-to-conditionally-noareg-a-fn</link><description> Hi All. 
 
Imagine a function that looks like this: 
DEFINED_SYMBOL1
type FnName(args) DEFINED_SYMBOL2
{
 ...;
} By appropriate definition of DEFINED_SYMBOL1 and DEFINED_SYMBOL2, I would like to end up with: type FnName(args)
{
 ...;
} or #pragma NOAREGS</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How to conditionally NOAREG a fn?</title><link>https://community.arm.com/thread/95138?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2002 15:38:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:abd48114-22c1-4c0e-9b4c-cdf8448193b5</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;we try to avoid having any compiler-specific code in our *.c source files. &lt;br /&gt;
&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Excellent!&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;For the pragmas, we conditionally include a file...&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
That sounds clever - I&amp;#39;ll bear it in mind if I need to do such a thing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to conditionally NOAREG a fn?</title><link>https://community.arm.com/thread/54602?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2002 11:21:22 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8c4a454f-53b0-4f2a-a878-61a26f906b75</guid><dc:creator>Andrew E. Kalman</dc:creator><description>&lt;p&gt;Hi Guys.&lt;br /&gt;
&lt;br /&gt;
Thanks for the replies. &lt;br /&gt;
&lt;br /&gt;
The method I&amp;#39;m now using is like what Andrew suggested, but taken one step further because we try to avoid having any compiler-specific code in our *.c source files. &lt;br /&gt;
&lt;br /&gt;
How do we do that? &lt;br /&gt;
&lt;br /&gt;
Well, the reentrant stuff is easy because it&amp;#39;s a keyword. For the pragmas, we conditionally include a file just prior to the function of interest. In that file, if the compiler is C51 AND that particular function is the one we&amp;#39;re interested in AND it needs the pragma (all based on values of defined symbols), then the pragma is all that comes out of that file. And we undo the pragma after the file ...&lt;br /&gt;
&lt;br /&gt;
With this &amp;quot;include-file method&amp;quot; we&amp;#39;re able to keep the *.c source files reasonably legible ...&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
&lt;br /&gt;
Andrew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to conditionally NOAREG a fn?</title><link>https://community.arm.com/thread/39062?ContentTypeID=1</link><pubDate>Tue, 20 Aug 2002 08:08:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a65e3f61-f4c7-4915-8a9a-16c1647f59ee</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;One C rule you must obey is that you can&amp;#39;t have a pre-proc. directive in a pre-proc. directive. E.g.&lt;pre&gt;#define ILLEGAL  #pragma &lt;/pre&gt;won&amp;#39;t work.&lt;br /&gt;
&lt;br /&gt;
There is an exception for token pasting and concatenation, e.g.&lt;pre&gt;#define STRINGER(x)    #x
#define STRING_CAT(x, y) STRINGER(x) ## STRINGER(y)&lt;/pre&gt;Which can be fun.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to conditionally NOAREG a fn?</title><link>https://community.arm.com/thread/39058?ContentTypeID=1</link><pubDate>Tue, 20 Aug 2002 03:26:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:349213f2-c351-433a-900a-a236b148d6ee</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;How about:&lt;pre&gt;#if defined( USE_REENTRANT )
// Use the Keil C51 &amp;#39;reentrant&amp;#39; extended keyword
#define REENTRANT reentrant
#else
// Do not use &amp;#39;reentrant&amp;#39; - the expansion is nothing!
#define REENTRANT
#endif

#if defined( USE_NOAREGS )
// The NOAREGS Compiler Option has been requested
#pragma NOAREGS
#endif
type FnName(args) REENTRANT
{
 ...;
}&lt;/pre&gt;Where your predefined symbols are USE_REENTRANT and USE_NOAREGS &lt;br /&gt;
&lt;br /&gt;
NB: The USE_REENTRANT techniques illustrates a good way to &amp;quot;isolate&amp;quot; all your compiler-dependencies - just use &lt;b&gt;__C51__&lt;/b&gt; as your predefined symbol&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>