Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Namespaces and macros (C++ - VC6)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Radu Carlan
New Member

Australia
2 Posts

Posted - Jan 31 2008 :  12:58:58 AM  Show Profile  Reply with Quote

Hi,

We have been using Visual Assist for several years in a team of six developers on a C++ codebase of over 2 million lines of code. The level of acceptance is reasonably high throughout the team. I personally would rather code with just one hand than not use Visual Assist .

Anyway, the reason for this post is that we are increasingly affected by what could be viewed as a limitation (or even defect) in Visual Assist:

We use a deeply nested structure of namespaces to organise a relatively large C++ codebase (2+ MLoC). In order to make our lives easier (and to provide some degree of standardisation in an otherwise decentralised system of namespaces), we employ a collection of macros. For example:


// n1.h

#define BEGIN_N1  namespace n1 \                  { /* n1 */

#define END_N1    } /* n1 */

#define N1        n1
#define USING_N1  using N1


// n2.h

#include G?n1.hG?

#define BEGIN_N2  BEGIN_N1       \                    namespace n2 \                    { /* n2 */

#define END_N2      } /* n2 */   \                  END_N1

#define N2        N1::n2
#define USING_N2  USING_N1::n2


This allows us to write code that looks like this:


// c.h

#include G?n2.hG?

BEGIN_N2

class C
{
  public:
    static C* GetC() {return new C;}
    void M() {}
};

END_N2


which is arguably easier to read and to maintain, especially if the namespace structure should happen to change. Of course, we use proper (descriptive) names for our namespaces, macros, classes, methods, functions, etc. The above is just for illustration.

We have discovered that if we use the macros in declarations of local variables, the Visual Assist IntelliSense doesnG??t work properly:


#include G?c.hG?

void f()
{
  N2::C* c = N2::C::GetC();    // no VA IntelliSense
  c->M();                      // no VA IntelliSense
  delete c;
}


The same block of code (in the same compilation unit) re-engineered to not use the namespace definition macro works properly:


#include G?c.hG?

void f()
{
  n1::n2::C* c = n1::n2::C::GetC();  // VA IntelliSense OK
  c->M();                            // VA IntelliSense OK
  delete c;
}


Is there anything that can be done about this?

We are very reluctant to drop the usage of macros for namespace definitions. Aside from the benefits (we believe) we get from using the macros, we have a lot of legacy code that employs them extensively (and we wouldnG??t want to have to hire a regular expressions guru to engineer the macros out of the existing code).

Thanks,
Radu Carlan

Chief Software Architect
CorProfit Systems Australia


feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 31 2008 :  08:42:54 AM  Show Profile  Reply with Quote
I am seeing similar problems here, with my simplified version of this:

case=11759

For now you may find that adding helper #define's to VA stdafx.h file helps. I the file as explained in this FAQ entry:

http://docs.wholetomato.com?W302

and added the entries:

#define BEGIN_N2 namespace n2 { n1 {
#define END_N2 } }
#define N2 n2::n1

at the bottom. This file is used to help VA's parser with difficult code, and can be used to work around odd effects. After modifying this file you need to rebuild the VA symbol database for the changes to take effect:

VA Options -> Performance -> General -> Rebuild symbol databases

This helped somewhat in my code. Depending on just how many namespaces, and how many combinations you have, this may or may not help you.

zen is the art of being at one with the two'ness
Go to Top of Page

Radu Carlan
New Member

Australia
2 Posts

Posted - Jan 31 2008 :  5:17:17 PM  Show Profile  Reply with Quote
Unfortunately, editing VA's stdafx.h is not feasible for us. We have over 60 namespaces defined using macros and new ones are added all the time. Furthermore, the namespace definitions are distributed across multiple header files G?? i.e. there is no singular header file to contain them all. Then, there's also the issue of updating all developers machines with the latest stdafx.h whenever somebody in the team adds a namespace definition. Not to mention having to also manage updates that future builds of Visual Assist may make to this file G?? especially in the context of having to synchronise them across all developersG?? machines.

Having said that, I did try your suggestion of adding explicit namespace definition macros to VA's stdafx.h and indeed the VA IntelliSense seems to now cope with them.

Will this issue be addressed in a future build of Visual Assist? If so, is there an ETA for it?

Thanks,
Radu
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Feb 01 2008 :  08:14:49 AM  Show Profile  Reply with Quote
We are looking into the problem, via case=11759

Unfortunately I do not have any estimate on this yet.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000