<?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>can constants defined in a file be used in other file without defining ?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/33199/can-constants-defined-in-a-file-be-used-in-other-file-without-defining</link><description> i have defined 
 #define key0 0x35 
in main file and now i want to use key0 in one of included file in this project 
but on compilation i get error for this. 
Does keil have any provision where i can use defined constants 
of one file in other file without</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: can constants defined in a file be used in other file without defining ?</title><link>https://community.arm.com/thread/95322?ContentTypeID=1</link><pubDate>Sat, 25 Jan 2003 17:54:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:59ebd696-77dc-4e0f-89a5-f2ca3e04ce62</guid><dc:creator>Richard Collett</dc:creator><description>&lt;p&gt;Arjun asked:&lt;br /&gt;
&amp;gt; doubt!! --&amp;gt; KEYS_H_HDR&lt;br /&gt;
&amp;gt; (#ifndef KEYS_H_HDR&lt;br /&gt;
&amp;gt; #define KEYS_H_HDR )&lt;br /&gt;
&amp;gt; Does this should be same as header file &amp;gt; name ?&lt;br /&gt;
&lt;br /&gt;
The label name is arbitrary, but it keeps things neat to make it the same as the header filename.&lt;br /&gt;
This is a very common technique to avoid &amp;quot;multiple definition&amp;quot; errors if the same header file is referred to twice. (The first reference will &amp;quot;define&amp;quot; KEYS_H_HDR, so a second reference will &amp;quot;comment out&amp;quot; the entire contents of the header file.&lt;br /&gt;
&lt;br /&gt;
If your C textbook does not refer to header files, then get another one. This is a fundamental part of the C language.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can constants defined in a file be used in other file without defining ?</title><link>https://community.arm.com/thread/95325?ContentTypeID=1</link><pubDate>Sat, 25 Jan 2003 04:55:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:75e93555-1179-4201-84fb-fdb097b7611c</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;book to which i had reffered did not carry detail about this.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
In that case, it does not qualify as a &amp;quot;good&amp;quot; book on &amp;#39;C&amp;#39; - this is fundamental stuff.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;Is it neccessary that header file created by us should be kept in &amp;quot;inc&amp;quot; folder.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
No.&lt;br /&gt;
As with any application trying to find a file, there are certain &lt;i&gt;default&lt;/i&gt; locations where the compiler will look, and a certain order in which it will try the alternatives - or you can &lt;i&gt;&lt;b&gt;explicitly&lt;/b&gt;&lt;/i&gt; state the file&amp;#39;s location by includinging a full or relative path.&lt;br /&gt;
You need to read the Compiler &lt;b&gt;Manual&lt;/b&gt; for details. For C51, see the &lt;b&gt;INCDIR&lt;/b&gt; directive.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can constants defined in a file be used in other file without defining ?</title><link>https://community.arm.com/thread/54950?ContentTypeID=1</link><pubDate>Sat, 25 Jan 2003 02:48:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d0548550-1ba9-4852-9e8d-36aefb05867a</guid><dc:creator>arjun pal</dc:creator><description>&lt;p&gt;Thanks Vaclav &amp;amp; Andrew&lt;br /&gt;
I am new to programming in C,book to which i had reffered did not carry detail about&lt;br /&gt;
this.&lt;br /&gt;
&lt;br /&gt;
Is it neccessary that header file created&lt;br /&gt;
by us should be kept in &amp;quot;inc&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
doubt!! --&amp;gt; KEYS_H_HDR&lt;br /&gt;
(#ifndef KEYS_H_HDR&lt;br /&gt;
 #define KEYS_H_HDR )&lt;br /&gt;
Does this should be same as header file name ?&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can constants defined in a file be used in other file without defining ?</title><link>https://community.arm.com/thread/39680?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2003 05:36:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8cfddd54-f1c3-42e1-9740-3757ab004caa</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Does keil have any provision...&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
this is absolutely standard &amp;#39;C&amp;#39; stuff - nothing special about Keil!&lt;br /&gt;
&lt;br /&gt;
I suggest that you need to get a good, standard &amp;#39;C&amp;#39; text book.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: can constants defined in a file be used in other file without defining ?</title><link>https://community.arm.com/thread/39673?ContentTypeID=1</link><pubDate>Fri, 24 Jan 2003 05:23:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:55502fa5-a646-4445-9f01-e080e18666bb</guid><dc:creator>Vaclav Korecek</dc:creator><description>&lt;p&gt;Create your own header file, for example &amp;quot;keys.h&amp;quot;&lt;br /&gt;
and include it in any file which use&lt;br /&gt;
defines of the header file.&lt;br /&gt;
&lt;br /&gt;
/* header file */&lt;br /&gt;
#if !defined(KEYS_H_HDR)&lt;br /&gt;
#define KEYS_H_HDR&lt;br /&gt;
&lt;br /&gt;
#define key0  0x35&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
/* in source file use (for example) ...  */&lt;br /&gt;
#include &amp;quot;keys.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Vaclav&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>