Book a Demo

Author Topic: Error when creating a #define for a namespace  (Read 2434 times)

Hoff

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Error when creating a #define for a namespace
« on: April 09, 2010, 11:01:38 pm »
Hello,
I am programming in C++. I've created a class diagram, and inside it I've put the Package "nsA", and inside it I've put the namespace "nsB". Then, inside "nsB", I've put the class "ClassTst" with a simple "TstOp" function.

Then I generate the code, and the generated code was:

Code: [Select]
namespace nsA
{
      namespace nsB
      {
            class ClassTst
            {

            public:
                  ClassTst();
                  virtual ~ClassTst();

                  void TstOp();

            };
      }
}

Ok, very good so far.

But then I changed my code to use a #define for the namespaces and included a new function, as follows:


Code: [Select]
#define NS_A_B namespace nsA { namespace nsB{
#define END_NS_A_B }}
      
      
NS_A_B
class ClassTst
{

public:
      ClassTst();
      virtual ~ClassTst();

      void TstOp();

      void Func2();

};
END_NS_A_B

Then I tried to synchronize the code with the diagram, but the following error ocurred:

"There was an error parsing C:\ClassTst.h on line 16. Unexpected symbol: ClassTst.
Would you like to continue the import?"

I pressed "YES", but it was unable to import the new function.


Is it possible to do what I am trying to do?

Thanks!