<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Classic/Legacy CodeWarriorのトピックRe: Dividing the code in various .c files</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136400#M930</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dividing up a C program into separate files is a fundamental part of programming in C. I strongly suggest you find a good book or website on C, and look up how to structure code in this way.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Jun 2007 16:15:48 GMT</pubDate>
    <dc:creator>sjmelnikoff</dc:creator>
    <dc:date>2007-06-11T16:15:48Z</dc:date>
    <item>
      <title>Dividing the code in various .c files for PowerPC program</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136398#M928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 3;"&gt;I am new to code warrior.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 3;"&gt;I am building a C application on powerpc,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 3;"&gt;Since my main code is very big with lots of fuctions, there our some global structures which these functions update after recieving values from UARTs.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 3;"&gt;I want to divide my code in various .C files, as in the global structures stay in main and the functions are grouped in various .c files. They update the data structures they way they do it in main.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 3;"&gt;Please help me how this can be done.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 3;"&gt;~Cheers&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by J2MEJediMaster on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-06-11&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;10:16 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 10 Jun 2007 19:47:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136398#M928</guid>
      <dc:creator>xainub</dc:creator>
      <dc:date>2007-06-10T19:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136399#M929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Actually I don't know how to implement code division in various C files in Code Warrior&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2007 13:02:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136399#M929</guid>
      <dc:creator>xainub</dc:creator>
      <dc:date>2007-06-11T13:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136400#M930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dividing up a C program into separate files is a fundamental part of programming in C. I strongly suggest you find a good book or website on C, and look up how to structure code in this way.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2007 16:15:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136400#M930</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2007-06-11T16:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files for PowerPC program</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136401#M931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I have done it before,&lt;/DIV&gt;&lt;DIV&gt;but Actually I was having problems with extern this time&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2007 02:10:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136401#M931</guid>
      <dc:creator>xainub</dc:creator>
      <dc:date>2007-06-12T02:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files for PowerPC program</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136402#M932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Well, globals are best avoided. But if you must:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;Header.h:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;extern unsigned int MyVar; /* Declaration */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;File1.c&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;#include "Header.h"&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;...&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;unsigned int MyVar; /* Definition */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;...&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;MyVar = 3; /* Use */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;File2.c&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;#include "Header.h"&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;...&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;MyVar = 3; /* Use */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2007 15:48:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136402#M932</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2007-06-12T15:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files for PowerPC program</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136403#M933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanx alot, I will try keeping all in one header file and adding it in all,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Would it be a okay even if i declare them in the common header file rather than main.c?&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2007 22:16:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136403#M933</guid>
      <dc:creator>xainub</dc:creator>
      <dc:date>2007-06-12T22:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files for PowerPC program</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136404#M934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;The &lt;EM&gt;declaration&lt;/EM&gt; (the bit with the &lt;FONT face="Courier New"&gt;extern&lt;/FONT&gt;) must be visible to any source (.c) file which uses the variable, so the common practise is to put it in a header (.h) file, and &lt;FONT face="Courier New"&gt;#include&lt;/FONT&gt; that header wherever the variable is required. The definition&amp;nbsp;acts just like a function prototype.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The &lt;EM&gt;definition&lt;/EM&gt; can only exist in one place, as it allocates the space for the variable, so &lt;STRONG&gt;must&lt;/STRONG&gt; be in a source (.c) file. In that respect, it behaves like a function body.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Again, I strongly recommend that you find a good C reference, and read up on this subject.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2007 15:22:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136404#M934</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2007-06-13T15:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dividing the code in various .c files for PowerPC program</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136405#M935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hey, thanx alot, I tried it and its working now&lt;/DIV&gt;&lt;DIV&gt;I was reading few tutorials, but i had this query and which clearly wasn't answered anywhere.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I will do more studyin on this.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanx again.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2007 22:14:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Dividing-the-code-in-various-c-files-for-PowerPC-program/m-p/136405#M935</guid>
      <dc:creator>xainub</dc:creator>
      <dc:date>2007-06-13T22:14:55Z</dc:date>
    </item>
  </channel>
</rss>

