Help with Header files.
-
I have a dll that includes a particular header file. In my main application code it too uses the same same header file. When I include the header file for my dll it tries to inclue the header file twice. How do I get the compiler to only include the file if it has not already been loaded? Example: DLL.h File - #include "Myheader.h" MainApp.h File - #include "Myheader.h" #include "DLL.h" Thanks for the help, -Eric
-
I have a dll that includes a particular header file. In my main application code it too uses the same same header file. When I include the header file for my dll it tries to inclue the header file twice. How do I get the compiler to only include the file if it has not already been loaded? Example: DLL.h File - #include "Myheader.h" MainApp.h File - #include "Myheader.h" #include "DLL.h" Thanks for the help, -Eric
In Myheader.h:
#ifndef MYHEADER_H_INCLUDED
#define MYHEADER_H_INCLUDED// header contents here...
#endif
There is also the
#pragma once
command, however I prefer the#ifdef
method so that I can test for the presence of the symbol to tell whether a header has been included. --Mike-- When 900 years old you reach, look as good you will not. Hmm. 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm -
I have a dll that includes a particular header file. In my main application code it too uses the same same header file. When I include the header file for my dll it tries to inclue the header file twice. How do I get the compiler to only include the file if it has not already been loaded? Example: DLL.h File - #include "Myheader.h" MainApp.h File - #include "Myheader.h" #include "DLL.h" Thanks for the help, -Eric
-
I have a dll that includes a particular header file. In my main application code it too uses the same same header file. When I include the header file for my dll it tries to inclue the header file twice. How do I get the compiler to only include the file if it has not already been loaded? Example: DLL.h File - #include "Myheader.h" MainApp.h File - #include "Myheader.h" #include "DLL.h" Thanks for the help, -Eric
The standard way to prevent multiple inclusion of a header file is to add this in each .h file. This example depicts foo.h.
#ifndef foo_h
#define foo_h
...
#endif/ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com