Solved

PP Namespace Question

Posted on 1998-11-21
2
214 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 48
set up trigger (or something) to rename files (starting with ATL) in a linux directory 6 53
substring method in java 1 98
move a line in eclipse 3 83
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 …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

21 Experts available now in Live!

Get 1:1 Help Now