answersLogoWhite

0


Best Answer

Every header file is located in a directory. You use a compiler option (-I) to specify include directory to the compiler.

Example:

gcc -W -Wall -pedantic -I/my/favourite/directory -o prog.o -c prog.c

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you include an user defined header file that is located in a directory?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Where headers files are generally stored?

It depends on the header file and on the general organization of the project. System header files, such as stdio.h or windows.h, are stored in a directory that the compiler knows about, but that you don't need to even think about. Library header files are either stored in the same place that system header files are stored, or they are stored in a place reserved for the particular library. In the latter case, there will usually be build parameters that identify the header files and their associated library files. User header files are either stored in the same directory as the source files, or they can be stored in a related directory, somewhere in the project directory tree. well in most of the DOS/Windows C/C++ compilers predefined header files are stored in INCLUDE directory of the folder containing the compiler


Which number of header files available in c?

Just go to your compiler's include directory, and count the files, there can be dozens of them (Or hundreds. Or more.)


What header file should include to enable string conversion in c?

What conversion do you mean? For example strtol is defined in stdlib.h, sprintf is defined in stdio.h.


How do you create a user defined header file?

Header files are not much different from usual cpp files. There are basically two different things. It's file extension: you need to choose "header file" when you create it or save as .h file. Second is header files do not have main() function. When you are done with you header file do not forger to include it in your project by writing preprocessor directive:#include "your_header_file.h"


How can you create a headerfile in a c?

Create the header file as a .h file in the same way you create a source file, .c and place it in the same directory as the .c files. To incorporate it, use the... #include "my_header_file.h" ... directive. Note that there are double quotes instead of greater/less signs. This tells the compiler to look first in the source directory.


Contrast the IPv4 and the IPv6 header fields?

Simplified header format. IPv6 has a fixed length header, which does not include most of the options an IPv4 header can include. Even though the IPv6 header contains two 128 bit addresses (source and destination IP address) the whole header has a fixed length of 40 bytes only. This allows for faster processing. Options are dealt with in extension headers, which are only inserted after the IPv6 header if needed. So for instance if a packet needs to be fragmented, the fragmentation header is inserted after the IPv6 header. The basic set of extension headers is defined in RFC 2460.


To include a header or footer in a publication you will have to view the .?

To include a header or footer in a publication you will have to view the .?


How do you include a system header file called sysheader.h in a c source file?

There is no system header called share.h, but if there were, it would be: #include <share.h>


How is the header file include within a program?

#include or#include "nameoftheader"


Why is it necessary to include header files in C?

It isn't necessary to include header files in C. However, without the functionality provided by some header files, your program wouldn't be able to do very much that is useful.


How do you begin a page of C plus plus coding?

It depends whether you are writing a header or a source file. Generally you will begin with the header, and this should always begin with a header guard: // file: my_header.hpp #ifndef _MY_HEADER_HPP_ #define _MY_HEADER_HPP_ //... // header code goes here // ... #endif _MY_HEADER_HPP_ Although the opening header guard should always be placed first, it's a good idea to precede the header guard with a multi-line comment briefly explaining the purpose of the header and its contents, as well as the author's contact details and any required copyright notifications. The header code will include any other required headers as well as any required forward declarations, followed by its own declarations. You may also include definitions for those declarations, however its generally best to keep implementation details separate from the declarations. The only exceptions are when declaring class templates, which must be completely defined in the header, or when defining implicit inline functions. The corresponding source file must include the header file, along with any other header files for its forward declarations, before defining the implementations of the header's undefined declarations. Other files that require those definitions need only include the corresponding header file.


I am coding OpenGL game I have to include some header files to use in many files. so that I'd an error . function template has already been defined ... any hints here?

Place header guards around your header files to prevent them being included more than once during a compilation, regardless of how many files include them.E.g., if your header file is called MyClass.h, use the following template:#ifndef _MYCLASS_H_#define _MYCLASS_H_// all header code goes here#endif _MYCLASS_H_Header guards are typically in all upper case (as per all macro definitions) based upon the filename with leading and trailing underscores and an underscore replacing the period.Microsoft C++ also permits the use of the #pragma oncecompiler directive to achieve the same end. Most programmers use both conventions for portability.Note that not all headers need to include other headers. Forward declarations often suffice for headers unless the header requires access to a concrete type. As a rule of thumb, use a forward declaration in the header and an include in the source file. If the compiler complains about incomplete types within your header, include the required header in your header, remove the forward declaration, and remove the include from the source.