<?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>function point</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/31609/function-point</link><description> flowing is error,Please help me!! 
 
#include &amp;lt;stdio.h&amp;gt; 
#define NUMBER 2 
 
 
int max(int a[]) 
 { 
	int z; 
	if(a[0]&amp;gt;a[1]) z=a[0]; else z=a[1]; 
	return(z); 
	} 
 
 
 
int process(void (* fun)(void *p),void *arg) 
	{ 
	int z; 
	z=(int *)(* fun)((int</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: function point</title><link>https://community.arm.com/thread/54729?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2002 07:35:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a92f15ca-37f4-4925-9511-d5c0d5b00d4a</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Having fixed these problems, be sure to search both the App Notes and the Knowledgebase - the limitations of the 8051 architecture put some serious constraints on the use of function pointers in C51.&lt;br /&gt;
You &lt;b&gt;will&lt;/b&gt; get some &lt;i&gt;&lt;b&gt;very&lt;/b&gt;&lt;/i&gt; obscure bugs if you don&amp;#39;t carefully observe all the precautions...!&lt;br /&gt;
&lt;br /&gt;
Search this forum, too.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: function point</title><link>https://community.arm.com/thread/39248?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2002 07:12:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:edfbcd60-dc39-4223-8a91-9ec51a565002</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;Your code is based on an invalid assumption, and it contains various bugs.&lt;br /&gt;
&lt;br /&gt;
Generally speaking, it&amp;#39;s almost always an error to cast a function pointer to any other function pointer type.&lt;br /&gt;
&lt;br /&gt;
On top of that, the casts you do apply are wrong, here:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
int z;
z=(int *)(* fun)((int *)arg); 
&lt;/pre&gt;
&lt;br /&gt;
The cast to (int *) is seriously wrong. You have to cast &amp;quot;fun&amp;quot; back to the real signature before you&amp;#39;re allowed to use it for calling max(), which will fix the return type in the same step:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;

typedef int (*my_fp_type)(int *);

int z;
z=((my_fp_type)fun)((int *)arg); 
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: function point</title><link>https://community.arm.com/thread/54728?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2002 01:09:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0be88b50-eb63-441c-b515-2ec32a482b8f</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;Sorry.  I said:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;It appears you have the loop &lt;b&gt;termination&lt;/b&gt; expression and the loop iteration expression reversed.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
That should be &lt;b&gt;test&lt;/b&gt;, not &lt;b&gt;termination&lt;/b&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: function point</title><link>https://community.arm.com/thread/39250?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2002 00:53:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:cb9525cd-32ec-4156-b20d-bd53167e1bd3</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;&lt;pre&gt;#include &amp;lt;stdio.h&amp;gt;
#define NUMBER 2

int max(int a[])
{
    int z;
    if(a[0]&amp;gt;a[1]) z=a[0]; else z=a[1];
    return(z);
}

int process(void (* fun)(void *p),void *arg)
{
    int z;
    z=(int *)(* fun)((int *)arg);&lt;/pre&gt;
In the line above, the usage does not match the declaration.&lt;br /&gt;
&lt;pre&gt;    return(z);
}

main()
{
    int a[NUMBER];
    int i;
    int d;
    for(i=0;i++;i&amp;lt;NUMBER) a[i]=i;&lt;/pre&gt;
The loop will never be entered.  It appears you have the loop termination expression and the loop iteration expression reversed.&lt;br /&gt;
&lt;pre&gt;
    d=process(max,a);&lt;/pre&gt;
The first argument has a type mismatch, implicitly attempting to convert an int (*)(int *) to a void (*)(void *)&lt;br /&gt;
&lt;pre&gt;    while(1);
}&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>