Solved

PP Namespace Question

Posted on 1998-11-21
2
212 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 98
how do i create updater to My Activex application? 3 74
no14 challenge 14 56
post4 challenge 28 81
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now