Class redefinition error
-
1)Actually, what i am doing is to integrate two separate Excel & access automation applications into one. 2)First, i finish Excel automation(used excel9.olb(library) & included excel9.h as header file).Upto now it works fine. 3)Now The problem begins. For access automation functionality i use msacc9.olb & include access9.h as header file.As soon as i compile, even before adding any functionality, it shows class redefinition errors for _Application etc. Apparently, these are due to the object models of Excel & Access which have some same class names like _Application etc. which cause the clash. There seems nothing wrong with the code but with the libraries of access & excel which have some same class names. How should i resolve the clash?Please, Please, Please Help!!:(( Ankush Mehta
-
1)Actually, what i am doing is to integrate two separate Excel & access automation applications into one. 2)First, i finish Excel automation(used excel9.olb(library) & included excel9.h as header file).Upto now it works fine. 3)Now The problem begins. For access automation functionality i use msacc9.olb & include access9.h as header file.As soon as i compile, even before adding any functionality, it shows class redefinition errors for _Application etc. Apparently, these are due to the object models of Excel & Access which have some same class names like _Application etc. which cause the clash. There seems nothing wrong with the code but with the libraries of access & excel which have some same class names. How should i resolve the clash?Please, Please, Please Help!!:(( Ankush Mehta
in your headers, did you thought to well add such code :
#if !defined (__MY_HEADER_H_INCLUDED__)
#define __MY_HEADER_H_INCLUDED__// your header content here...
#endif //__MY_HEADER_H_INCLUDED__
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -
in your headers, did you thought to well add such code :
#if !defined (__MY_HEADER_H_INCLUDED__)
#define __MY_HEADER_H_INCLUDED__// your header content here...
#endif //__MY_HEADER_H_INCLUDED__
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0]No, i didn't add any such code.where should i add it.please tell in detail. Ankush Mehta
-
No, i didn't add any such code.where should i add it.please tell in detail. Ankush Mehta
i thought it was clear enough... it must round all your definitions in the header it is on... so, the
#if
and#define
must be before what you declare in the header (others#include
can be before that, as they may have their own exclusive statements already) ans the#endif
put at the end of the file... if you have several headers in that case, choose different#define
macros for each header, to avoid any problems... you could look into any compiler header to see how to do...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -- modified at 5:39 Wednesday 14th December, 2005 -
i thought it was clear enough... it must round all your definitions in the header it is on... so, the
#if
and#define
must be before what you declare in the header (others#include
can be before that, as they may have their own exclusive statements already) ans the#endif
put at the end of the file... if you have several headers in that case, choose different#define
macros for each header, to avoid any problems... you could look into any compiler header to see how to do...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -- modified at 5:39 Wednesday 14th December, 2005well, please forgive me for asking rather stupid questions. i am a newbie.Let me restate what i have done. the libraries msacc9.olb,excel9.olb provided by ms-office for automation are added to the project.These libraries contain header files msacc9.h & excel9.h. i include these header files at the top of the .cpp file of my application like this. #include"msacc9.h" #include"excel9.h" Now, please give me directions to resolve the clash(classes like _Application are in both libraries) Ankush Mehta -- modified at 6:13 Wednesday 14th December, 2005
-
well, please forgive me for asking rather stupid questions. i am a newbie.Let me restate what i have done. the libraries msacc9.olb,excel9.olb provided by ms-office for automation are added to the project.These libraries contain header files msacc9.h & excel9.h. i include these header files at the top of the .cpp file of my application like this. #include"msacc9.h" #include"excel9.h" Now, please give me directions to resolve the clash(classes like _Application are in both libraries) Ankush Mehta -- modified at 6:13 Wednesday 14th December, 2005
The directives that toxcct suggested you to add should enclose all the 'code' in all of your .h files. Are you using AppWizard to generate the files for new classes ? If yes, these directives are automatically inserted in your code. So if this is the case, the problem is probably elsewhere. Then post the exat and COMPLETE error message.
-
The directives that toxcct suggested you to add should enclose all the 'code' in all of your .h files. Are you using AppWizard to generate the files for new classes ? If yes, these directives are automatically inserted in your code. So if this is the case, the problem is probably elsewhere. Then post the exat and COMPLETE error message.
yes, it seems that he does have 2 different headers defining each a _Application class...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0] -
yes, it seems that he does have 2 different headers defining each a _Application class...
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20][VisualCalc 3.0]yeah, toxcct you are right. Following errors are generated: error C2011: 'FormatConditions' : 'class' type redefinition error C2011: 'Module' : 'class' type redefinition error C2011: 'Modules' : 'class' type redefinition error C2011: '_Application' : 'class' type redefinition These classes exist in both the headers(but they have different definitions.e.g, _Application object is an open access db for access header file while _Application object for excel header file is an open excel).I have used appwizard to generate related files.These headers are provided by msoffice. Any Ideas please...... Ankush Mehta
-
yeah, toxcct you are right. Following errors are generated: error C2011: 'FormatConditions' : 'class' type redefinition error C2011: 'Module' : 'class' type redefinition error C2011: 'Modules' : 'class' type redefinition error C2011: '_Application' : 'class' type redefinition These classes exist in both the headers(but they have different definitions.e.g, _Application object is an open access db for access header file while _Application object for excel header file is an open excel).I have used appwizard to generate related files.These headers are provided by msoffice. Any Ideas please...... Ankush Mehta
What line i am following................ i heard of namespace.as i am a newbie, i am not sure about this.at the top of my main .cpp file i tried using this: namespace anyname1 { #include "msacc9.h" } namespace anyname2 { #include "excel9.h" } But this again didn't work out... Seeking help......Please.........:(( Ankush Mehta