<?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>query:definition of func in C</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/15408/query-definition-of-func-in-c</link><description> Hi all 
 
 
 include&amp;lt;stdio.h&amp;gt;
 #define ....

 void xyz(); &amp;lt;---- i am referring to this defn of xyz()

 void abc()
 {
 -:statements:-
 }

 void main()
 {
 abc();
 xyz();
 }

 void xyz()
 {
 -:statements:-
 }
 
 
 Is it compulsory to define all the Routines</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: query:definition of func in C</title><link>https://community.arm.com/thread/84382?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2003 04:11:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c81aac28-13ae-411d-8ed4-df9edaa72544</guid><dc:creator>arjun pal</dc:creator><description>&lt;p&gt;Thanks neil &amp;amp; graham&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: query:definition of func in C</title><link>https://community.arm.com/thread/55016?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2003 03:46:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:28869bb3-2868-447b-b06c-6e45138ac201</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;A definition of a function may be provided by a prototype&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Strictly, a Prototype provides only a &lt;i&gt;&lt;b&gt;declaration&lt;/b&gt;&lt;/i&gt; of a function; a matching &lt;i&gt;&lt;b&gt;definition&lt;/b&gt;&lt;/i&gt; must also be provided.&lt;br /&gt;
&lt;br /&gt;
A &lt;i&gt;&lt;b&gt;declaration&lt;/b&gt;&lt;/i&gt; simply &lt;i&gt;&lt;b&gt;informs&lt;/b&gt;&lt;/i&gt; the compiler about the function - it gives just enough information to allow the compiler to generate calls to the function, and handle any return value; &lt;i&gt;ie,&lt;/i&gt; the function name, the number &amp;amp; type of any parameters, and the type of any return value.&lt;br /&gt;
&lt;br /&gt;
The &lt;i&gt;&lt;b&gt;definition&lt;/b&gt;&lt;/i&gt; provides the actual executable code to implement the function - the definition does not have to be in the same source file, or even the same language!&lt;br /&gt;
The Linker sorts this out - or gives an &amp;quot;Unresolved External&amp;quot; error if it can&amp;#39;t!&lt;br /&gt;
&lt;br /&gt;
As Graham said, you need to read-up on this in any standard &amp;#39;C&amp;#39; textbook.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: query:definition of func in C</title><link>https://community.arm.com/thread/39762?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2003 03:24:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ea69e0b1-15f1-4baf-8bfc-559a859bdab5</guid><dc:creator>Graham Cole</dc:creator><description>&lt;p&gt;This is really a C question and not at all specific to the Keil products. You need a good C book.&lt;br /&gt;
&lt;br /&gt;
However, yes you are right. A C compiler compiles source code in (notionally) a single pass: starting at the top and ending at the bottom. When the C compiler finds a reference to a function (or a variable or anything else) it must already have compiled a definition. A definition of a function may be provided by a prototype (as xyz in your example) or the function itself (as abc in your example).&lt;br /&gt;
&lt;br /&gt;
It is a common practice to arrange the code so that prototypes are kept to a minimum. It is often possible to write a program with no prototypes at all. Note that this necessarily means that main() will appear at the end of the source code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>