Can I include a user written .h file within the .h file in C ???
Can I include a user written .h file within the .h file in C ???
Recent thread
http://cboard.cprogramming.com/showt...hlight=include
The answer can't fulfil my query.
Sappose I make a header file named gtool.h and within this .h file I include that gtool.h
Is that exceptable?
Why would you want to? No, it's not acceptable. If you include the same file you're currently in, you'll get a loop, and the compiler will error.
I recently Buy a book named Graphics programing in c by BPB publication.Wher I found a user written file
named gtools.h and there I see the gtools.h included within the header file.Can u send me a sample user written header file by which i draw both rectangle and circle (as per example)
I exactly want to know how I right the code. So pls help me with your enormous skill!
That was probably a publishing error -- just comment out the recursive include. Many books are netorious for publishing bad, unedited code.
but, consider this...
andCode:#include "any.h"
are not the same!Code:#include <any.h>
hello fnoyan...
As we know for a use defined header file we use to include header file in double quotes like "Header.h" . and inbuilt header in angle brackets, like <Header.h>. But why this difference is there and how compiler treats to both.
S_ccess is waiting for u. Go Ahead, put u there.
Some applicatons you write may need special definitions and you put them into your own header file.On some systems, like UNIX, an ordinary user cannot copy a header file into one of the standart header lookup directories for compiler.
In most of C++ programs class definitions and implementations are done in different files and included in the main file.
You can specify your own header include directory for the compiler and may use <anyhile.h> instead of "anyfile.h" even if your header is not in the predefined header include path. For example, if you use gcc you can specify the current directory as a standart include file lookup directory as follows
I think there is no difference between both type of include from the compiler point of view.Code:gcc -L./ prog.c
gcc uses -I for additional include paths, not -L. -L is for additional library path searches.
depends on the compiler -- some compilers do not distinguish between quotes and brackets.Originally Posted by fnoyan
U are talking about compiler dependent views. But what does the ANSI standard says about these two.Originally Posted by Ancient Dragon
S_ccess is waiting for u. Go Ahead, put u there.
Thank u all. Ur knowledge will help me to spread my idea and depth on c & c++. Thanks for debating on my topic
From section 6.10.2 of the standard:Originally Posted by maven
2 A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identified uniquely by
the specified sequence between the < and > delimiters, and causes the replacement of that
directive by the entire contents of the header. How the places are specified or the header
identified is implementation-defined.
3 A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the source file identified
by the specified sequence between the " delimiters. The named source file is searched
for in an implementation-defined manner. If this search is not supported, or if the search
fails, the directive is reprocessed as if it read
# include <h-char-sequence> new-line
with the identical contained sequence (including > characters, if any) from the original
directive.
If you understand what you're doing, you're not learning anything.