Inclusion of header files
-
Thank you Pallini. #program once is already there in all the header files except in MyClass.h.When I tried to include, I am getting the errors 'CMyClass' : is not a class or namespace name syntax error : identifier 'CMyClass' syntax error : missing ';' before '}' syntax error : missing ';' before '}' . . . . . fatal error C1003: error count exceeds 100; stopping compilation
Taruni
What is the source file the error is given for? Have you included
MyClass.h
in that source file?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
What is the source file the error is given for? Have you included
MyClass.h
in that source file?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]In adding to the generated classes for SDI application (all the .h files however has #pragma once statements and all .cpp files have #include "stdafx.h" statements) , I am writing a serializable class(CMyclass) that is derived from CObject. In the MyClass.h file, I am including "stdafx.h" (as the header file for CObject and others) file and in the MyClass.cpp file, I am including "MyClass.h" file . Upto this point the application compiles nicely. But whenever I include "MyClass.h" in "MyTrialDoc.h" (in order to create a global object of CMyClass) I get that the compiler limit.When I tried to include #pragma once , I got all the errors which I have mentioned in my previous post.
Taruni
-
In adding to the generated classes for SDI application (all the .h files however has #pragma once statements and all .cpp files have #include "stdafx.h" statements) , I am writing a serializable class(CMyclass) that is derived from CObject. In the MyClass.h file, I am including "stdafx.h" (as the header file for CObject and others) file and in the MyClass.cpp file, I am including "MyClass.h" file . Upto this point the application compiles nicely. But whenever I include "MyClass.h" in "MyTrialDoc.h" (in order to create a global object of CMyClass) I get that the compiler limit.When I tried to include #pragma once , I got all the errors which I have mentioned in my previous post.
Taruni
The compiler reports the source file under compilation when the error occurs. This piece of info is important, please post it. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi, I have created an SDI application and created a new class "CMyClass" that is derived from CObject. So I have included the header file "stdafx.h/afx.h " in CMyClass.h. I am trying to create an object of CMyClass in CMyDoc.h and for this purpose I have to include MyClass.h.When I do so and compile I am getting the "warning C4182: #include nesting level is 360 deep; possible infinite recursion" and "fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit". In order to solve the problem , I have maximum tried to minimize the inclusion of header files. But couldn't. How to solve this problem? Thanks in advance.
Taruni
Instead of placing #include in your CMyClass.h, put is as the first line in CMyClass.cpp. That will most likely resolve the problem. Good luck. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Instead of placing #include in your CMyClass.h, put is as the first line in CMyClass.cpp. That will most likely resolve the problem. Good luck. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
Thank you krmed. I have even tried that. When I tried to include "stdafx.h" in .cpp files, I am getting the error "error C2504: 'CObject' : base class undefined". As the other alternatives I have even tried including "afx.h" and "afxwin.h" . But in vain.
Taruni
-
The compiler reports the source file under compilation when the error occurs. This piece of info is important, please post it. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi, I have created an SDI application and created a new class "CMyClass" that is derived from CObject. So I have included the header file "stdafx.h/afx.h " in CMyClass.h. I am trying to create an object of CMyClass in CMyDoc.h and for this purpose I have to include MyClass.h.When I do so and compile I am getting the "warning C4182: #include nesting level is 360 deep; possible infinite recursion" and "fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit". In order to solve the problem , I have maximum tried to minimize the inclusion of header files. But couldn't. How to solve this problem? Thanks in advance.
Taruni
Taruni wrote:
So I have included the header file "stdafx.h/afx.h " in CMyClass.h.
Under normal circumstances, there's no need to do this.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Hi, I have created an SDI application and created a new class "CMyClass" that is derived from CObject. So I have included the header file "stdafx.h/afx.h " in CMyClass.h. I am trying to create an object of CMyClass in CMyDoc.h and for this purpose I have to include MyClass.h.When I do so and compile I am getting the "warning C4182: #include nesting level is 360 deep; possible infinite recursion" and "fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit". In order to solve the problem , I have maximum tried to minimize the inclusion of header files. But couldn't. How to solve this problem? Thanks in advance.
Taruni
Was your project compiling correctly prior to creating
CMyClass
? What does thestdafx.h
file look like? The top ofCMyClass.cpp
should look like:#include "stdafx.h"
#include "myclass.h"Do you concur?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
Was your project compiling correctly prior to creating
CMyClass
? What does thestdafx.h
file look like? The top ofCMyClass.cpp
should look like:#include "stdafx.h"
#include "myclass.h"Do you concur?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
Thank you David. If I include those header files in .cpp file, then the compiler generates the error as it doesn't find the header file for CObject in MyClass.h file.Again if I include afx.h (which is usually indirectly included by stdafx.h in MyClass.h file in order to solve, the error "compiler limit: internal heap limit is reached " is once again generated.
Taruni
-
Thank you David. If I include those header files in .cpp file, then the compiler generates the error as it doesn't find the header file for CObject in MyClass.h file.Again if I include afx.h (which is usually indirectly included by stdafx.h in MyClass.h file in order to solve, the error "compiler limit: internal heap limit is reached " is once again generated.
Taruni
Taruni wrote:
If I include those header files in .cpp file, then the compiler generates the error as it doesn't find the header file for CObject in MyClass.h file.
Which is why I asked what the
stdafx.h
file looks like. At this point, I would create a "dummy" MFC project, and then create your new class via Insert --> New Class. In the Class Type combobox, select Generic Class. In the Derived From box, typeCObject
. Study the contents of the files created."Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch