Click here to Skip to main content
15,900,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalhelp me!!! Pin
kookoorikoo9-Mar-05 9:06
kookoorikoo9-Mar-05 9:06 
GeneralRe: help me!!! Pin
Ylis9-Mar-05 9:27
Ylis9-Mar-05 9:27 
GeneralProblem with main MDI Frame window Pin
Anonymous9-Mar-05 8:56
Anonymous9-Mar-05 8:56 
GeneralRe: Problem with main MDI Frame window Pin
Ryan Binns9-Mar-05 17:30
Ryan Binns9-Mar-05 17:30 
GeneralInclude Help Needed Pin
Jeryth9-Mar-05 7:53
Jeryth9-Mar-05 7:53 
GeneralRe: Include Help Needed Pin
David Crow9-Mar-05 8:06
David Crow9-Mar-05 8:06 
GeneralRe: Include Help Needed Pin
Jeryth9-Mar-05 13:12
Jeryth9-Mar-05 13:12 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard9-Mar-05 22:01
Steen Krogsgaard9-Mar-05 22:01 
I might give a shot at an explanation.

#pragma once (according to MSDN) instructs the compiler to include the header file only once in the compilation. This works from VC++ version 4 (I'm not sure about this, but VC++6.0 has _MSC_VER=1200, so I guess 5.0 is 1100 and 4.0 is 1000). If you use VC++ 6.0 then _MSC_VER is 1200 and #pragma once should be sufficient for you. You just have to put #pragma once in ALL your header files (and only the header files).

All AppWizard-generated MFC projects come with header files that looks like this:
<br />
// Ex2.h: interface for the CEx2 class.<br />
//<br />
//////////////////////////////////////////////////////////////////////<br />
<br />
#if !defined(AFX_EX2_H__9190AD6B_F3D4_4DC8_B8DF_C4F8460B0306__INCLUDED_)<br />
#define AFX_EX2_H__9190AD6B_F3D4_4DC8_B8DF_C4F8460B0306__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
......<br />
<br />
#endif // !defined(AFX_EX2_H__9190AD6B_F3D4_4DC8_B8DF_C4F8460B0306__INCLUDED_)<br />


The #if - #define - #endif constructs implements the same idea as you do with your "own tags", but here the whole header file text is surrounded by the #if/#endif statements. I really can't see why that should be much different from putting #if/#endif around the #include statements instead, but maybe that's why it doesn't work for you. Anyway, as I see it the #if/#endif is redundant to #pragma once. In any event, the AFX_blah_blah_blah is just MFC's way of making a unique tag (AFX + filename + guid), if your tags are unique then they should work equally well.

Are you absolutely sure that your problems stems from multiple inclusions of the classA header? You can trace the parsing of your header files by putting a #pragma message (see MSDN) in the header file.

Cheers
Steen.

"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
GeneralRe: Include Help Needed Pin
Jeryth10-Mar-05 1:11
Jeryth10-Mar-05 1:11 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard10-Mar-05 1:25
Steen Krogsgaard10-Mar-05 1:25 
GeneralRe: Include Help Needed Pin
Jeryth10-Mar-05 5:18
Jeryth10-Mar-05 5:18 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard10-Mar-05 5:27
Steen Krogsgaard10-Mar-05 5:27 
GeneralRe: Include Help Needed Pin
Jeryth10-Mar-05 6:11
Jeryth10-Mar-05 6:11 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard 210-Mar-05 7:34
Steen Krogsgaard 210-Mar-05 7:34 
GeneralRe: Include Help Needed Pin
Jeryth14-Mar-05 5:50
Jeryth14-Mar-05 5:50 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard 214-Mar-05 9:32
Steen Krogsgaard 214-Mar-05 9:32 
GeneralRe: Include Help Needed Pin
Jeryth14-Mar-05 17:29
Jeryth14-Mar-05 17:29 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard 217-Mar-05 7:15
Steen Krogsgaard 217-Mar-05 7:15 
GeneralRe: Include Help Needed Pin
Steen Krogsgaard10-Mar-05 1:28
Steen Krogsgaard10-Mar-05 1:28 
GeneralRe: Include Help Needed Pin
Jeryth10-Mar-05 4:40
Jeryth10-Mar-05 4:40 
Generalexecution! Pin
mpapeo9-Mar-05 7:42
mpapeo9-Mar-05 7:42 
GeneralRe: execution! Pin
David Crow9-Mar-05 8:12
David Crow9-Mar-05 8:12 
GeneralRe: execution! Pin
mpapeo9-Mar-05 8:26
mpapeo9-Mar-05 8:26 
GeneralRe: execution! Pin
David Crow9-Mar-05 8:57
David Crow9-Mar-05 8:57 
GeneralRe: execution! Pin
mpapeo9-Mar-05 10:04
mpapeo9-Mar-05 10:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.