<?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>Returning multiple values from a function??</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31675/returning-multiple-values-from-a-function</link><description> 
I want a function to return multiple values after doing data
processing i.e. void test(int a, int b int c) whereas a, b and c have
values set and control is returned to the caller with the values sent
back. 
Try as I may I haven&amp;#39;t been able to return</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/128532?ContentTypeID=1</link><pubDate>Thu, 03 Apr 2014 02:56:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:97c9ecf4-5c48-4e11-b447-49b290e93e4f</guid><dc:creator>Kevin Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
And of course, the goto is especially when making a nice software
delay loop.&lt;/p&gt;

&lt;p&gt;
As mentioned in that link, their use breaks the amount of
optimization the compiler can carry out, so obviously code execution
times becomes so much more predictable.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/117522?ContentTypeID=1</link><pubDate>Thu, 03 Apr 2014 02:34:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fdd3ec4f-3f8d-4088-a3f3-2a3a21daa035</guid><dc:creator>Ash J</dc:creator><description>&lt;p&gt;&lt;p&gt;
for some people who love goto:&lt;br /&gt;
&lt;br /&gt;
goto: - the 1st time in my life i m using goto with some thing
related to C :P (punintended)&lt;br /&gt;
&lt;a href="http://www.keil.com/forum/12771/"&gt;http://www.keil.com/forum/12771/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
There are many more threads on this forum. you can just read them,
before using goto.&lt;/p&gt;

&lt;p&gt;
PS: I ain&amp;#39;t no against it. But till date haven&amp;#39;t found any purpose
of using it. Neither have stumbled across a single circumstance where
i could not code without using &lt;b&gt;goto&lt;/b&gt;.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/107596?ContentTypeID=1</link><pubDate>Thu, 03 Apr 2014 02:14:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:00b28c5b-cb23-41f7-ba6a-714cb5d24926</guid><dc:creator>Kevin Michael</dc:creator><description>&lt;p&gt;&lt;p&gt;
Use lists or arrays. The array is my favourite.&lt;/p&gt;

&lt;p&gt;
If you&amp;#39;re coding in C there are many many ways to do this. Give it
a google.&lt;/p&gt;

&lt;p&gt;
Also try to use more gotos. They&amp;#39;re underrated.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/93153?ContentTypeID=1</link><pubDate>Thu, 03 Apr 2014 00:28:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8ffa0962-7434-4ca9-a99d-44859395e4c8</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The &amp;quot;traditional&amp;quot; route, for people who don&amp;#39;t see limitations but
possibilities with the programming language, would probably look
like:&lt;/p&gt;

&lt;pre&gt;
int my_function(my_struct* result) {
    if (!result) {
        return RES_NAUGHTY_TRICKSTER;
    }

    result-&amp;gt;charlie = 1.6180339887;
    result-&amp;gt;benny = 2.7182818;
    result-&amp;gt;johnny = 3.14159265;
    return RES_OK;
}
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
So the &amp;quot;return&amp;quot; is if the function could perform or not, while the
struct gets the result of the computation - but only valid if the
function returned an OK.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/62705?ContentTypeID=1</link><pubDate>Wed, 02 Apr 2014 23:12:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:74ccdc0f-ecbf-4a15-864c-a5f52cd7888c</guid><dc:creator>Ash J</dc:creator><description>&lt;p&gt;&lt;p&gt;
It seems u dont know the &amp;#39;&lt;b&gt;pass by reference&lt;/b&gt;&amp;#39; method of
passing the variables. You may not even want to return multiple
values if you know the advantages of &lt;b&gt;pass by reference&lt;/b&gt;
technique.&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://denniskubes.com/2012/08/20/is-c-pass-by-value-or-reference/"&gt;denniskubes.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/118482?ContentTypeID=1</link><pubDate>Wed, 02 Apr 2014 15:28:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a387efbc-f3d5-4834-8651-9068f8e9fdb9</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
It seemed appropriate in the context, I&amp;#39;ll put it back in my pants
now.&lt;/p&gt;

&lt;p&gt;
&lt;a href="https://www.youtube.com/watch?v=zebvFBNZ3Mg"&gt;www.youtube.com/watch&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/93155?ContentTypeID=1</link><pubDate>Wed, 02 Apr 2014 14:11:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6d5db8c9-0b87-4aa5-99c8-10826a0e3b76</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Even farmers do these days.&lt;/p&gt;

&lt;p&gt;
Old Mac Donald. EI, EIO.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/68605?ContentTypeID=1</link><pubDate>Wed, 02 Apr 2014 13:17:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6685bc88-30b5-4e19-8433-73b327f81c2a</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;I read from someone C doesn&amp;#39;t support multiple
returns&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&amp;quot;Someone&amp;quot; being none other than Messrs Kernighan &amp;amp; Ritchie -
the authors of the language?&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;is this correct?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Yes.&lt;/b&gt; Any decent textbook should be clear on this.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;Is this just in Keil?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;No.&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;I really want to avoid using ... structs if at all
possible.&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;Why?&lt;/b&gt; That would be the usual way to do it.&lt;/p&gt;

&lt;p&gt;
Or pass the parameters by &lt;b&gt;reference&lt;/b&gt; (pointer)?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Returning multiple values from a function??</title><link>https://community.arm.com/thread/62703?ContentTypeID=1</link><pubDate>Wed, 02 Apr 2014 13:14:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:316b4bf3-ea0d-4e47-95d6-cfb0aef88c53</guid><dc:creator>Westonsupermare Pier</dc:creator><description>&lt;p&gt;&lt;p&gt;
Heaven forbid you read the C Language documentation.&lt;/p&gt;

&lt;p&gt;
Return a structure, a static one if you want, or pass in a
structure, and modify the values there in. Pass as pointers.&lt;/p&gt;

&lt;p&gt;
C is a systems programming language, PASCAL is more for academics,
they are polished differently to suit.&lt;/p&gt;

&lt;p&gt;
Westonsupermare Pier BEng (Hons)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>