?
Solved

PP Namespace Question

Posted on 1998-11-21
2
Medium Priority
?
229 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 800 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

765 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