<?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>declaration after function call</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/20022/declaration-after-function-call</link><description> I just started using kile c51 compiler with &amp;#181;Vision. 
My problem is only a stylistic issue. 
 
While initializing my controler: 
&amp;lt;dir&amp;gt; 
 
 unsigned char dummy1 = 0xFF;
 /* call openADC0 */
 openADC0( dummy1 );

 unsigned char dummy2 = 0xFF;
 /* call</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/149178?ContentTypeID=1</link><pubDate>Tue, 09 May 2006 01:46:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:adc93ff8-69cd-4b1d-bed0-234e857bef02</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Note that what you have learned here is standard ANSI &amp;#39;C&amp;#39; - nothing specifcally to do with Keil nor the 8051!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/130045?ContentTypeID=1</link><pubDate>Tue, 09 May 2006 01:35:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6e323a69-f64e-4eea-b98c-083f3d4de212</guid><dc:creator>Juljan Ciperd</dc:creator><description>&lt;p&gt;Thank you all very much for your know how and&lt;br /&gt;
for Your effort.&lt;br /&gt;
&lt;br /&gt;
I learned a lot and I hope I will be learning&lt;br /&gt;
a lot more here as well as in other threads.&lt;br /&gt;
&lt;br /&gt;
 Regards&lt;br /&gt;
J.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/123235?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 12:13:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:42a078e1-00c2-42ab-9797-55a42ff293b7</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;From the snippet given, I don&amp;#39;t see any point to having the variable at all, instead of passing the constant 0xFF directly to the function.  But perhaps there&amp;#39;s more to the actual code.&lt;br /&gt;
&lt;br /&gt;
ANSI C does permit declaration of local blocks, inside of which you can declare variables.  This is an often overlooked feature of C.  It&amp;#39;s sometimes handy to constrain the scope of temporary variables.  The following is legal ANSI C.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
     {
     unsigned int data dummy1 = 0xFF;

     func1 (dummy1);
     }

     {
     unsigned int data dummy2 = 0xFF;

     func2 (dummy2);
     }
&lt;/pre&gt;
Note that you can similarly declare variables inside any open brace of a block -- after an if, inside a while loop, and so on.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, C51 doesn&amp;#39;t really take advantage of the information about locality the programmer has provided.  For memory allocation purposes, it essentially just promotes the locals, so the above code will take up 4 bytes of &amp;quot;stack&amp;quot; when it really only needs 2.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/112074?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 09:34:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fe31ffe4-22d8-4fa3-80c7-03a3a00fa36b</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Being able to declare variables is a feature of C++.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Errr... I think you missed a bit there?!&lt;br /&gt;
&lt;br /&gt;
Something like: &lt;i&gt;&amp;quot;Being able to define variables &lt;/i&gt;&lt;b&gt;in the middle of a block&lt;/b&gt;&lt;i&gt; is a feature of C++.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Both declaring and defining variables are, of course, entirely possible in &amp;#39;C&amp;#39;!  ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/98070?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 08:55:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d7b6c3d0-0d1b-4a47-97eb-6c272638a216</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;i&gt;Thanks, I know but is there realy no compiler instruction for keil?&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
No, since turning a C compiler into a somewhat-but-not-quite C++ compiler does not make much sense.&lt;br /&gt;
&lt;br /&gt;
Being able to declare variables is a feature of C++. If you are using a C compiler, then write C code, not some C/C++ hybrid code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/98075?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 08:55:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:25deedc8-0db4-48f9-8c7a-c30e5804f5d2</guid><dc:creator>Juljan Ciperd</dc:creator><description>&lt;p&gt;No. I think You&amp;#39;re right.&lt;br /&gt;
&lt;br /&gt;
But thanks a lot anyway&lt;br /&gt;
 J.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/98068?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 08:55:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:239accc3-2406-45fb-855b-caaba865f32d</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Thanks, I know&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
But, aparently, you didn&amp;#39;t understand.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;is there realy no compiler instruction for keil?&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
No, there isn&amp;#39;t.&lt;br /&gt;
&lt;br /&gt;
Keil C51 is an &lt;b&gt;ANSI &amp;#39;C&amp;#39;&lt;/b&gt; compiler, and &lt;b&gt;ANSI &amp;#39;C&amp;#39;&lt;/b&gt; does not permit this.&lt;br /&gt;
&lt;br /&gt;
C++ does allow it, but &lt;b&gt;ANSI &amp;#39;C&amp;#39;&lt;/b&gt; does &lt;b&gt;&lt;i&gt;not&lt;/i&gt;&lt;/b&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/74021?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 08:50:51 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f986c95d-cb6f-424c-a0b4-1e6566a67ec8</guid><dc:creator>Juljan Ciperd</dc:creator><description>&lt;p&gt;Thanks, I know but is there realy no compiler&lt;br /&gt;
instruction for keil?&lt;br /&gt;
&lt;br /&gt;
 Regards&lt;br /&gt;
J.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: declaration after function call</title><link>https://community.arm.com/thread/46025?ContentTypeID=1</link><pubDate>Mon, 08 May 2006 08:45:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a29161b4-aae0-4011-8dbc-e0964555c909</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;i&gt;Why am I not allowed to daclare another&lt;br /&gt;
variable, after I called a function!&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Because you are using a &lt;b&gt;C&lt;/b&gt; compiler, not a &lt;b&gt;C++&lt;/b&gt; compiler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>