Board index » cppbuilder » ensure only 1 include of *.h file

ensure only 1 include of *.h file


2006-09-07 03:20:44 AM
cppbuilder60
Hi,
I would like to know how we can for BCB to only include 1 instance of
*.h file, in case it is declared in several *.cpp or other *.h files.
i include only once the file "shlobj.h" within my class.
However, when i use my class in some other class, BCB informs me that in
the file "shlobj.h", there are multiple declaration for several types...
like [C++ Error] shobjidl.h(2372): E2238 Multiple declaration for
'FOLDERSETTINGS'
But i'm sure that i only included once this *.h file.
and everything is under #ifndef, #define and #endif...
thx,
AL.
 
 

Re:ensure only 1 include of *.h file

--== Alain ==-- < XXXX@XXXXX.COM >writes:
Quote
Hi,

I would like to know how we can for BCB to only include 1 instance of
*.h file, in case it is declared in several *.cpp or other *.h files.

i include only once the file "shlobj.h" within my class.
However, when i use my class in some other class, BCB informs me that
in the file "shlobj.h", there are multiple declaration for several
types... like [C++ Error] shobjidl.h(2372): E2238 Multiple declaration
for 'FOLDERSETTINGS'

But i'm sure that i only included once this *.h file.

and everything is under #ifndef, #define and #endif...
You should not be defining things in your header file in the first
place. It should only declare types, etc. Otherwise you'll get
multiple definitions.
If a header file can only be included once in a whole project, it's
rather useless.
If you'd like help fixing the problem with your header, please post
some actual code (a small example (<= 50 LOC) that accurately
demonstrates the problem.) Thanks.
--
Chris (TeamB);
 

Re:ensure only 1 include of *.h file

Try putting NO_WIN32_LEAN_AND_MEAN in the conditional defines.
Don
 

{smallsort}

Re:ensure only 1 include of *.h file

"--== Alain ==--" < XXXX@XXXXX.COM >wrote in message
Quote
I would like to know how we can for BCB to only include 1
instance of *.h file, in case it is declared in several *.cpp or
other *.h files.
That is what header guards are specifically for. Not all headers
(especially third-party headers) use header guards, though.
Quote
i include only once the file "shlobj.h" within my class.
However, when i use my class in some other class, BCB informs
me that in the file "shlobj.h", there are multiple declaration for
several types... like [C++ Error] shobjidl.h(2372): E2238
Multiple declaration for 'FOLDERSETTINGS'
You need to add NO_WIN32_LEAN_AND_MEAN to your project's Conditionals list
in order to address that particular issue.
Gambit