Solved

PP Namespace Question

Posted on 1998-11-21
2
221 Views
Last Modified: 2013-12-26
I am having a problem with PP namespaces.  When I create a project using standard Pro4 project stationary and build this project, I can reference PP classes directly with no namespace qualifier.  For example, I can write:

            RegisterClass_(LWindow);

(i.e., no "PP::" in front of the LWindow class name.)
However (and this is my question/problem), I have a project that came with Pro4 that is a debugging sample (specifically, "Debugging Classes Demo").  Everywhere I reference a PP class, I must prefix it with "PP::" OR put "PP_Begin_Namespace_PowerPlant/PP_End_Namespace_PowerPlant" pairs around my code.  This is annoying and causes other problems (such as references to unqualified, global functions are now messed up).  In the projects where I do NOT have to prefix with PP:: I see nothing different than in this debug project settings or include files I am having problems with.

Any ideas on why some projects are different than others in this namespace respect?   Is there a project setting or some magic define somewhere that is in the stationary projects that is not set in this debug project?

Thanks,

Scott
Taggart@taggarts.org
0
Comment
Question by:staggart
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
boonstra earned 200 total points
ID: 1291598
The #define you are looking for is PP_Uses_PowerPlant_Namespace.  Metrowerks is migrating PowerPlant to use its own namespace.  Some of the newer example code sets this #define to 1 (in Debugging Classes Demo it is in DebugSample_PCH.cp.  In your older code, this symbol is probably not defined, so the namespace feature isn't used.

From the PP 1.9.1 release notes:

* Added a PowerPlant namespace controlled via macros
  PP_Macros.h #define's
    PP_Begin_Namespace_PowerPlant
    PP_End_Namespace_PowerPlant
   
  controlled by the symbol
    PP_Uses_PowerPlant_Namespace
   
  The default value for PP_Uses_PowerPlant_Namespace is 0 (false)
  for this release. In the future, it will default to true.
 
  If you wish to activate the PowerPlant namespace, put
    #define PP_Uses_PowerPlant_Namespace 1
  in your prefix file.
 
  If you do activate the PowerPlant namespace, you will need
  to explicity qualify PowerPlant types or use a "using"
  declaration. For example,
 
    PowerPlant::LPane  *thePane;  // explicit qualifier
   
  or
 
    using namespace PowerPlant;    // using declaration
   
    LPane  *thePane;        // Refers to PowerPlant::LPane
   
  For convenience, you may want to define a namespace alias:
 
    namespace PowerPlant { }    // Forward declaration
    namespace PP = PowerPlant;    // Alias
   
    PP::LPane  *thePane;      // Use alias. Less typing.
   
  The forward declaration of the PowerPlant namespace is needed
  if you define your alias before #include'ing any PP code,
  such as in a prefix file.
   
  A subtle issue with namespaces occurs with forward class
  declarations. You need to specify the namespace. For example,
 
    class LPane;    // Will get errors if using namespaces
   
    namespace PowerPlant {  // The right way
      class LPane;  // forward declaration with namespaces
    }
   
  Or, if you want to use the conditional macros:
   
    PP_Begin_Namespace_PowerPlant
      class LPane;
    PP_End_Namespace_PowerPlant
0
 

Author Comment

by:staggart
ID: 1291599
Thanks for the answer - it was very complete and good.  Unfortunately, I found this out about a day after I posted the message.  Thanks anyway - you deserve the points.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question