<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: C Programming :: How to use a variable in multiple/different source files?</title>
	<atom:link href="http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/</link>
	<description>C++, C, VB.NET, PCB, Electronics, Circuit Design</description>
	<lastBuildDate>Sat, 26 Dec 2009 14:02:38 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Circuit Negma</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11163</link>
		<dc:creator>Circuit Negma</dc:creator>
		<pubDate>Mon, 23 Mar 2009 13:59:39 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11163</guid>
		<description>1. &gt;&gt; How do you open up that picture file
Click on the following link :: &lt;a href=&quot;http://circuitnegma.wordpress.com/2009/03/23/extract-files-embedded-in-pictures/&quot; rel=&quot;nofollow&quot;&gt;http://circuitnegma.wordpress.com/2009/03/23/extract-files-embedded-in-pictures/&lt;/a&gt;

2. &gt;&gt; the golobal variables issue
I am going to make a project and post it here.</description>
		<content:encoded><![CDATA[<p>1. &gt;&gt; How do you open up that picture file<br />
Click on the following link :: <a href="http://circuitnegma.wordpress.com/2009/03/23/extract-files-embedded-in-pictures/" rel="nofollow">http://circuitnegma.wordpress.com/2009/03/23/extract-files-embedded-in-pictures/</a></p>
<p>2. &gt;&gt; the golobal variables issue<br />
I am going to make a project and post it here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xCruiser</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11161</link>
		<dc:creator>xCruiser</dc:creator>
		<pubDate>Mon, 23 Mar 2009 11:50:22 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11161</guid>
		<description>How do you open up that picture file? :-s Sorry but I don&#039;t know how to extract it and I, too, am having problems with global variable and using it in different files. Please do help me. It&#039;s giving me some linkage error. :(</description>
		<content:encoded><![CDATA[<p>How do you open up that picture file? :-s Sorry but I don&#8217;t know how to extract it and I, too, am having problems with global variable and using it in different files. Please do help me. It&#8217;s giving me some linkage error. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Circuit Negma</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11073</link>
		<dc:creator>Circuit Negma</dc:creator>
		<pubDate>Wed, 25 Feb 2009 12:30:17 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11073</guid>
		<description>To Debayan,

It is possible to initialize the variables/functions in the main program after including common.h header in the main program, but doing so, on a large scale software will cause you problems of keeping track of all of the variables and functions.

by defining the common.c file, you will be more organized and be able to change/modify variables and functions easily for large programs.

it also always you to reuse common.c and common.h files in other projects. where as if you define and initialize your variables and functions in the main program, you will not be able to use these variables and functions in other future projects.

think of common.h and common.c as a one packaged library, that can be used and reused over and over again across multiple projects.

Also, by using such structure, you will be able to read and scroll through your main program and codes easily. Imaging you have a program that is 2000 lines long all jammed into one main file. if you are using one those basic IDEs, you will have problem reading, debugging and analyzing you code. where as if you break your code into headers and declaration files, your main code will shrink down to a couple of 100 lines that you will be able to read, manage, debug, and analyze easily.</description>
		<content:encoded><![CDATA[<p>To Debayan,</p>
<p>It is possible to initialize the variables/functions in the main program after including common.h header in the main program, but doing so, on a large scale software will cause you problems of keeping track of all of the variables and functions.</p>
<p>by defining the common.c file, you will be more organized and be able to change/modify variables and functions easily for large programs.</p>
<p>it also always you to reuse common.c and common.h files in other projects. where as if you define and initialize your variables and functions in the main program, you will not be able to use these variables and functions in other future projects.</p>
<p>think of common.h and common.c as a one packaged library, that can be used and reused over and over again across multiple projects.</p>
<p>Also, by using such structure, you will be able to read and scroll through your main program and codes easily. Imaging you have a program that is 2000 lines long all jammed into one main file. if you are using one those basic IDEs, you will have problem reading, debugging and analyzing you code. where as if you break your code into headers and declaration files, your main code will shrink down to a couple of 100 lines that you will be able to read, manage, debug, and analyze easily.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: debayan</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11071</link>
		<dc:creator>debayan</dc:creator>
		<pubDate>Tue, 24 Feb 2009 14:07:36 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-11071</guid>
		<description>what is the need for common.c file? is it not possible to initialize the  variables/functions in the main program after including common.h header?</description>
		<content:encoded><![CDATA[<p>what is the need for common.c file? is it not possible to initialize the  variables/functions in the main program after including common.h header?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dennis</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10978</link>
		<dc:creator>Dennis</dc:creator>
		<pubDate>Sun, 18 Jan 2009 09:39:14 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10978</guid>
		<description>Hey THX A WHOOOOOOLE LOT!!!!

been pondering about this question for the whole day now and been searching and searching and didnt get ath (more like i don&#039;t know exactly what keyword to use for the search....tried &quot;using variables in different C files&quot; or sth liddat :P

anyway stumbled into this page and WALA eth solved!!! Very much appreciated!!!

btw am doing some PIC programming with many .c files for different parts of the program, built seperately. And now when i try combining those parts into one only then i realised this GLOBAL VARIABLE problem thingy.....and now its solved! ...oh yea~</description>
		<content:encoded><![CDATA[<p>Hey THX A WHOOOOOOLE LOT!!!!</p>
<p>been pondering about this question for the whole day now and been searching and searching and didnt get ath (more like i don&#8217;t know exactly what keyword to use for the search&#8230;.tried &#8220;using variables in different C files&#8221; or sth liddat <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>anyway stumbled into this page and WALA eth solved!!! Very much appreciated!!!</p>
<p>btw am doing some PIC programming with many .c files for different parts of the program, built seperately. And now when i try combining those parts into one only then i realised this GLOBAL VARIABLE problem thingy&#8230;..and now its solved! &#8230;oh yea~</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Circuit Negma</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10813</link>
		<dc:creator>Circuit Negma</dc:creator>
		<pubDate>Tue, 02 Sep 2008 19:25:51 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10813</guid>
		<description>To Mohit,

sorry for not responding as soon as possible.

I am not sure to why you are getting error, so I have included the following zipped project file for Dev-C++ v4.9.9.2

http://farm4.static.flickr.com/3227/2821772213_2b6f515415_o.jpg

Right click on the above link and save it to you harddisk, then open this picture using WINRAR or WINZIP to extract the project&#039;s files</description>
		<content:encoded><![CDATA[<p>To Mohit,</p>
<p>sorry for not responding as soon as possible.</p>
<p>I am not sure to why you are getting error, so I have included the following zipped project file for Dev-C++ v4.9.9.2</p>
<p><a href="http://farm4.static.flickr.com/3227/2821772213_2b6f515415_o.jpg" rel="nofollow">http://farm4.static.flickr.com/3227/2821772213_2b6f515415_o.jpg</a></p>
<p>Right click on the above link and save it to you harddisk, then open this picture using WINRAR or WINZIP to extract the project&#8217;s files</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohit</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10785</link>
		<dc:creator>Mohit</dc:creator>
		<pubDate>Fri, 22 Aug 2008 10:03:55 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10785</guid>
		<description>I am getting error while running main program .It says undefined reference to variable...

Please clarify.</description>
		<content:encoded><![CDATA[<p>I am getting error while running main program .It says undefined reference to variable&#8230;</p>
<p>Please clarify.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Circuit Negma</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10696</link>
		<dc:creator>Circuit Negma</dc:creator>
		<pubDate>Mon, 21 Jul 2008 12:28:09 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10696</guid>
		<description>variables that are declared globally, are by default set to static variables by the compiler.

since we have used the word &#039;extern&#039; in the declaration statement of i &amp; n, we do not need to include the word static, because &#039;extern&#039; will take care of setting up those variables as static variables.

the word &#039;extern&#039; will set a variable as a static variable and visible to all source files in the project. 

the word &#039;static&#039; is much used when you need to define global variables within a single source file and not to be shared with other source files in the project. thus, the scope of those global variables are only known to the source file that are being defined in it.

you could copy and paste the above codes into a new project then add the world &#039;static&#039; in header file only and try to compile the project. then remove &#039;static&#039; from header file and include them in the &#039;common.c&#039; source file and compile the project. then see for your self that the compiler will complain about using the word &#039;static&#039;.

I hope this would clear every thing for you.</description>
		<content:encoded><![CDATA[<p>variables that are declared globally, are by default set to static variables by the compiler.</p>
<p>since we have used the word &#8216;extern&#8217; in the declaration statement of i &amp; n, we do not need to include the word static, because &#8216;extern&#8217; will take care of setting up those variables as static variables.</p>
<p>the word &#8216;extern&#8217; will set a variable as a static variable and visible to all source files in the project. </p>
<p>the word &#8217;static&#8217; is much used when you need to define global variables within a single source file and not to be shared with other source files in the project. thus, the scope of those global variables are only known to the source file that are being defined in it.</p>
<p>you could copy and paste the above codes into a new project then add the world &#8217;static&#8217; in header file only and try to compile the project. then remove &#8217;static&#8217; from header file and include them in the &#8216;common.c&#8217; source file and compile the project. then see for your self that the compiler will complain about using the word &#8217;static&#8217;.</p>
<p>I hope this would clear every thing for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Circuit Negma</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10695</link>
		<dc:creator>Circuit Negma</dc:creator>
		<pubDate>Mon, 21 Jul 2008 12:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10695</guid>
		<description>defining i &amp; n in &#039;common.h&#039; will allow me to share those to variables across the entire project in case I need to access i &amp; n in another source file.

for example, I might have a lcd.c source file. for me to access and share i &amp; n back and forth; I need only to include common.h in lcd.c source file.

ex:
#include &quot;common.h&quot;

now lcd.c can read and write to i &amp; n variables.</description>
		<content:encoded><![CDATA[<p>defining i &amp; n in &#8216;common.h&#8217; will allow me to share those to variables across the entire project in case I need to access i &amp; n in another source file.</p>
<p>for example, I might have a lcd.c source file. for me to access and share i &amp; n back and forth; I need only to include common.h in lcd.c source file.</p>
<p>ex:<br />
#include &#8220;common.h&#8221;</p>
<p>now lcd.c can read and write to i &amp; n variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Li</title>
		<link>http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10690</link>
		<dc:creator>Kevin Li</dc:creator>
		<pubDate>Sat, 19 Jul 2008 21:28:13 +0000</pubDate>
		<guid isPermaLink="false">http://circuitnegma.wordpress.com/2008/07/16/c-programming-how-to-use-a-variable-in-multipledifferent-source-files/#comment-10690</guid>
		<description>Sorry, it should be in &#039;common.c&#039;.</description>
		<content:encoded><![CDATA[<p>Sorry, it should be in &#8216;common.c&#8217;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
