[aspectc-user] Namespace problems
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Wed Apr 18 12:57:28 CEST 2007
Hi,
this looks like an include-cycle problem (see section 5.1.1 of the ac++ compiler
manual). Does it work if you don't include "CConcreateFactory1.h" in your aspect
header file? You don't need this header file just for matching
"std::CConcreateFactory%".
- Olaf
Liu YueChang wrote:
> Hello everybody
>
> Could anybody tell me how can I solve this problem? The error message
> of this aspect c++ is so confused.
>
> I just try to use aspect c++ to write factory pattern. But I can not
> give the correct matching pattern because of the namespace. I think
> the namespase is a big problem in Aspect C++. It always give very blur
> error message.
>
> If I compile the following sourcecode, it said "error: invalid
> declaration near token `:'".
>
> The error just occur at CConcreateFactory1::CConcreateFactory1()
>
> Also, if I give a constructor inside the std::CAbstract, the compiler
> will report that the constructor name is invalid. I really confused.
>
> I am using aspect c++ with MinGW
>
> Thanks a lot.
>
> Richard
>
> The following is my source code:
>
>
> ////////////////////////////////////////////////////////////AAbstractFactory.ah
>
> #ifndef __AABSTRACTFACTORY_AH__
> #define __AABSTRACTFACTORY_AH__
> #include "CConcreateFactory1.h"
> #include "CAbstractProductA.h"
> #include "CAbstractProductB.h"
>
> aspect AAbstractFactory {
> advice "std::CConcreateFactory%" : slice class : public
> std::CAbstract {
> public:
> virtual std::CAbstractProductA createProductA() = 0;
> virtual std::CAbstractProductB createProductB() = 0;
> };
> };
> #endif
>
> ////////////////////////////////////////////////////////////CConcreateFactory1.cpp
>
> #include "CConcreateFactory1.h"
>
> namespace std
> {
>
> CConcreateFactory1::CConcreateFactory1()
> {
> cout << "construction of CConcreateFactory1" << endl;
> }
>
> CConcreateFactory1::~CConcreateFactory1()
> {
> cout << "destruction of CConcreateFactory1" << endl;
> }
>
> CAbstractProductA* CConcreateFactory1::createProductA()
> {
> return new CProductA1();
> }
>
> CAbstractProductB* CConcreateFactory1::createProductB()
> {
> return new CProductB1();
> }
> }
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user
More information about the aspectc-user
mailing list