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
 VAX gets confused with macros
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mikhail.matrosov
Senior Member

Russia
29 Posts

Posted - Jul 23 2014 :  07:33:22 AM  Show Profile  Reply with Quote
We use plugins framework which heavily exploits macros. These macros may introduce new methods and fields in class definition. In this case sove VAX functionality fails for methods of this class. I cannot navigate with Alt+G from method declaration to method definition and Create Implementation of a method generates stub as a global function,without MyClass:: prefix. If I comment out our macros, everything immediately works right.

Here is the code:
class MyClass : public msa::IObject, private msa::ObjectImpl {
public:
  ...
  // These lines are confusing:
  MSA_BEGIN_IMPLEMENT_IOBJECT;
  MSA_END_IMPLEMENT_IOBJECT;
...
}


That's how macros are defined:
#define MSA_BEGIN_IMPLEMENT_IOBJECTBASE\  private:\  msa::internal::Counter m_counter;\  \  public:\  virtual int AddRef() const\  {\    return m_counter.AddRef();\  }\  \  virtual int Release() const\  {\    int iLocalCounter = m_counter.Release();\    if (iLocalCounter == 0) delete this;\    return iLocalCounter;\  }\  \  virtual msa::Status QueryInterface(const char* in_IID, const void** out_ppObject) const\  {\    return msa::internal::RemoveConst(this)->QueryInterface(in_IID, const_cast<void**>(out_ppObject));\  }\  \  virtual msa::Status QueryInterface(const char* in_IID, void** out_ppObject)\  {\    msa::Status result;

#define MSA_END_IMPLEMENT_IOBJECTBASE\    return msa::STATUS_ENOINTERFACE;\  }

#define MSA_BEGIN_IMPLEMENT_IOBJECT \  MSA_BEGIN_IMPLEMENT_IOBJECTBASE

#define MSA_END_IMPLEMENT_IOBJECT \  MSA_END_IMPLEMENT_IOBJECTBASE \  void RegisterDeleteTracker(msa::INotifiable3* in_pObject,void* in_pParam)\  {\    msa::ObjectImpl::RegisterDeleteTracker(in_pObject, in_pParam);\  }\  void UnregisterDeleteTracked(msa::INotifiable3* in_pObject)\  {\    msa::ObjectImpl::UnregisterDeleteTracker(in_pObject);\  }\  virtual unsigned long GetThreadAffinity()\  {\    return msa::ObjectImpl::GetThreadAffinity();\  }\  virtual msa::Status MoveToThread(unsigned long in_ulThread)\  {\    return msa::ObjectImpl::MoveToThread(in_ulThread);\  }

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jul 23 2014 :  7:22:27 PM  Show Profile  Reply with Quote
It seems that Visual Assist gets confused by these macros. There are multiple solutions for this problem, but the easiest, safest and maybe the fastest way to workaround this is to create a file named va_stdafx.h next to your solution file with the following content:

#define MSA_BEGIN_IMPLEMENT_IOBJECT
#define MSA_END_IMPLEMENT_IOBJECT
// keep this comment - you need EOL to parse this correctly


This will override the macro for Visual Assist, so it will use empty ones, effectively skipping them.

You can learn more about this here:
http://docs.wholetomato.com/default.asp?W302

Edited by - accord on Jul 23 2014 7:26:05 PM
Go to Top of Page

mikhail.matrosov
Senior Member

Russia
29 Posts

Posted - Jul 24 2014 :  01:30:44 AM  Show Profile  Reply with Quote
Works like a charm, thanks! Any ideas on whether it will be fixed in the upcoming releases?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Jul 24 2014 :  3:43:34 PM  Show Profile  Reply with Quote
We are aware of problems with macros, and do work on them, but sometimes the easiest and best solution is to use the va_stdafx.h file, as you have, to give VA a helping hand. After all, the compiler gets to expand all of the macros before it has to think about the code, we don't get that luxury.

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