Solved

PP Namespace Question

Posted on 1998-11-21
2
219 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
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 473
fizzArray  challenge 1 96
mapBully challenge 6 152
Path of Workbook 3 86
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

837 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