Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Macro Expansion

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
pat Posted - Feb 12 2007 : 07:56:48 AM
What I'm really missing is a automatic macro expansion. I suggest a menu item in the refactoring popup when hovering on preprocessor macro names. If you hover the macro name at definition the expansion could be solution wide, so that all usages of this macro will be expanded. If one hovers the macro name at usage this single macro usage should be expanded.
27   L A T E S T    R E P L I E S    (Newest First)
SBone Posted - Jan 31 2013 : 2:38:15 PM
Since you are taking votes, I am also interested VERY MUCH in this feature. I'd be able to sell VAX to everyone else on my team, no problem. Several of them have switched to Eclipse just to get some bit of this functionality.
abraxas Posted - Aug 03 2011 : 11:18:39 AM
Yes, I am aware of the possibility to go to the macro definition and also that I will see the macro defintion on mouse over and it already is quite a help. Thanks for pointing out the definition field, it does help as well especially for classes that are defined through a macro.

I still think, to actually be able to see the expanded macro with the parameters I put into it, would make it a lot easier to follow what is going on inside the macro for a specific call.
samaursa Posted - Aug 03 2011 : 10:41:54 AM
I for one would buy/upgrade my license if VA included proper macro expansion similar to eclipse.
feline Posted - Aug 03 2011 : 10:27:26 AM
Are you aware that you can use Alt-g on the macro to go to the macro declaration? Also VA will try and show you the macro definition in its definition field, normally shown at the top of the editor, when the caret is inside the macro.

None of this is the same as macro expansion, but hopefully it will help a bit.
abraxas Posted - Aug 02 2011 : 04:21:00 AM
+1 for case 57776 ;)

I wouldn't want macros to be expanded in place inside the code, but it would definitely help to see for a specific use of a macro what will be made out of it. Especially when trying to decipher some third party or legacy code.

Actually this is the single most missed feature of VA X I can think of. Similar to eplawless' situation, I am the only VA X user in our company right now, but I am rather sure that the macro expansion feature alone would convince some of the other developers to go VA X.
feline Posted - Jul 25 2011 : 11:25:31 AM
We don't currently have a voting system, partly due to the number of bugs and feature request. Once you get past 20 or 30 a simple multiple choice vote gets very unwieldy.

We do keep a close eye on the forum, since this gives us some indication of how many users a given problem or feature request is effecting, and use this to help inform our decisions about what to fix or change next.
rryk Posted - Jul 24 2011 : 10:31:52 AM
quote:
Originally posted by feline

Am I reading your screen shots correctly? It actually takes 78 steps to fully expand this macro?


Yes. It is highly complex macro system.

quote:
I have put in a feature request for some form of dialog to expand / explore complex macro's to see what our developers make of it:

case=57776


Can we vote for feature requests, e.g. like in Google Code?
feline Posted - May 30 2011 : 11:33:02 AM
I have put in a feature request for some form of dialog to expand / explore complex macro's to see what our developers make of it:

case=57776

Some of these examples, you don't just want to expand the macro in place inside the code, which is what the original feature request was for.
eplawless Posted - May 28 2011 : 11:55:15 AM
This would be a great feature to add. I'm one of two VA X users in an office of about 15 programmers; the remainder are in various stages of being convinced that they'd want to use your software. Availability of macro expansion is one of the two questions that have come up repeatedly. It's possible that we'll pick up some additional licenses when this is implemented.
feline Posted - May 25 2011 : 1:22:17 PM
Am I reading your screen shots correctly? It actually takes 78 steps to fully expand this macro?

This is some rather complex macro code, I certainly see that.
rryk Posted - May 24 2011 : 9:04:57 PM
Having a simple definition of the macro in the Definition Window is not enough. Please let me illustrate the need for a complete macro expansion by showing some files from the project that I work with. Please download the archive here: http://dl.dropbox.com/u/16259710/macros.zip. Open MFFloat.hpp and try to resolve
RTSG_DECLARE_MFIELD_SHARED_PRIMITIVE_TYPE((MFFloat, std::vector<float>)
to the actual code. All files that contain nested macro definitions are also in archive. You will soon find out that it takes ages to do that manually. Eclipse can do this work for me even showing step-by-step how macros were expanded. Here are some screenshots:

http://i53.tinypic.com/5xsp7d.jpg
http://i51.tinypic.com/zwzz81.jpg
http://i54.tinypic.com/33cvxmp.jpg

In many other things Eclipse is much less convenient than Visual Studio with Visual Assist X. My hope is to have the best of two worlds.

P.S. It is possible to generate macro expansions using Visual Studio itself as described in here: http://fneep.fiffa.net/?p=66. This is, however, not very convenient as one has to run build and it does not generate step-by-step expansion as Eclipse does.
feline Posted - Mar 07 2011 : 3:59:56 PM
This is still in our list of enhancements to make to VA, but currently there has not been any progress on this.

Are you aware that VA shows you the macro definition in the Definition field when the caret is inside the macro name? I know this is not the same, but hopefully it will be of some help.
rryk Posted - Mar 06 2011 : 7:39:29 PM
In the project that I work with I have many nested macros which create tons of code (several methods). Eclipse is able to expand them to the actual code, which is very helpful sometimes. Visual Assist is already invaluable for me, but it can become even better with macro expansion feature.

Please do not advice me to get rid of macros, since I do not control part of the code which contains macros, but I build on top of the system and often have to deal with them. Original developer claims that it is very difficult (or even impossible) to do certain things in C++ without macros (do not ask me which ones - I don't know).

Any feedback from the developer? Is this feature planned in future versions? How soon should we expect it? Should we expect it at all?
pat Posted - Feb 22 2007 : 09:05:28 AM
Undo or RCS is ok for reversing changes.
KirillMueller Posted - Feb 22 2007 : 08:37:07 AM
Fine, thanks Contracting is calling for trouble, that's right. One can undo changes using the editor or a revision control system if needed.
schoenherr Posted - Feb 20 2007 : 12:36:50 AM
this suggestion sounds good to me, esspecially if you encounter a problem in a large macro i can expand it, rebuild my app and debug it properly.
feline Posted - Feb 19 2007 : 2:17:25 PM
With three people all seeing a use for this I have put in a feature request for expanding macro's:

case=5160

I still think that expanding and then "contracting" the macro is just asking for trouble though, so I have not mentioned this on the feature request.
sl@sh Posted - Feb 19 2007 : 07:38:59 AM
Well, even if you avoid macros like the plague, you rarely get to choose when it comes to legacy code that uses them. And yes, in such a case I would welcome a function that would replace one - or even better, all - instances of a specific macro call.
pat Posted - Feb 16 2007 : 7:13:05 PM
Thank your Kirill, I was beginning to worry about my programming style and that I'm the only one using macros somethimes ;)
KirillMueller Posted - Feb 16 2007 : 4:47:20 PM
I'd like to second pat's suggestion. Especially the simple variant of replacing one single invocation of a macro with its expanded textual equivalent, not touching any nested macros, is a feature I miss sometimes. If a macro is defined more than once (p.ex. a debug/release version), a menu could be offered. Replacing all invocations of a macro would be of limited use to me, although this would fit well into the collection of refactoring commands.
feline Posted - Feb 12 2007 : 2:28:06 PM
*ah* I managed to read your original statement back to front *oops*
pat Posted - Feb 12 2007 : 1:59:19 PM
quote:
Originally posted by feline

Personally I would look to templates before macro's.



I love templates but in some cases macros are irreplaceable!

quote:

Another aspect to all of this is how far should VA try and go when evaluating macro's? What about FALSE, TRUE, etc?



Again: VA should just expand ONE macro at once. I think there is no problem with TRUE/FALSE or stuff like that.
feline Posted - Feb 12 2007 : 1:32:20 PM
One big concern is the question of how this scales. I was discussing a test file, representative of real world code, with a user a little while ago. This file starts with 1,300 lines of macro's! Macro's are using macro's, and there are a lot of conditional macro's in there.

This is an extreme case, there is no doubt about it, but we do need to stop and consider the extreme cases, since this is where the trouble really starts. You have already said that you use macro's when they are the best solution, e.g. to create a class, this is a bit more complex than the simple one line test case

Problems with the debugger are one reason why I am very wary of macro's, plus the fact that they tend to make the code very hard to follow. Personally I would look to templates before macro's.

Another aspect to all of this is how far should VA try and go when evaluating macro's? What about FALSE, TRUE, etc?
pat Posted - Feb 12 2007 : 09:44:02 AM
Hm I'm a professional C++ programmer since over 14 years and I know very well about macros and the problems they may cause. But it's a C++ feature that can be used in a proper way. And in most of my projects I had contact with macros. Currently I'm working on a large library, with many classes that have similiar properties which I'm using macros for their definition. I avoid macros if I can, but in this case I need them.

Macro expansion is a thing I'm dreaming of for a long time, because I can remember many times I wished me this feature in VC. So it's not like I just want to expand some macros in a current project and hope that you would do the work for me ;). I would also be able to write some scripts by my self in this case. (_o_)

I really think this is an interesting feature for your VAssist refactoring module. May be there are other forum members, who think the same... we'll see - here in this thread.

Thank you for your fast responses feline.
feline Posted - Feb 12 2007 : 09:21:08 AM
Have a look at the macro here:

http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=4947#18888

I have seen MUCH more complex macro's being used in some people's code.

Personally I would view your situation as a good reason for not using macro's to begin with. How many different macro's are you looking at in your code? After you have expanded all of them then this feature in VA will be of no further use, so it seems like quite a lot of work for limited return.

The idea of reversing this, I am not keen on this at all, since it is opening a major can of worms.
pat Posted - Feb 12 2007 : 08:47:58 AM
Hm I can't see any problems with huge macros. And macros that are used in a macro that is about to expand shouldn't be expanded. One may expand them manually if liked.

Expansion of macros that are defined inside of preprocessor conditions should bring up a warning. Maybe this is really a case to avoid - so you're right at this point.

But nevertheless I would benefit by such a feature. Example: When I debug a program the VC debugger gives me no chance to debug the code inside a macro. So if I have complex macro code that needs to be debugged, I have to expand the macro by myself. Ok, this is no real issue. But an automatic expansion may have the following advantages:

1) The expansion of macro parameters would be much easier:

#define QUBIC(x) ((x)*(x)*(x))

printf( "%d", QUBIC(2) );         // using the macro
printf( "%d", ((2)*(2)*(2)) );    // expanded

2) Multi line macros can be formatted after expansion:

#define MY_CLASS(x) \  class x : base \  { \    int i; \\ 
  }

MY_CLASS(A);                        // using the macro

class A : base   {     int i;   };  // after expansion into a single line

class A : base 
  { 
    int i; 
  };                                // after expansion multi lined

class A : base 
{ 
  int i; 
};                                  // after formatting (ALT+F8)

3) It could be reversable with using special comments to surround the expanded code. Like this:

#define MY_MACRO "This is my macro string"

printf(MY_MACRO);  // with macro
printf(/*#MY_MACRO*/"This is my macro string"/*MY_MACRO#*/  // reversable expanded

Because this doesn't really look great (maybe it's acceptable with multiline macros), the reversable behaviour should be optional.
feline Posted - Feb 12 2007 : 08:11:31 AM
I am very warey of this, since what happens when the macro creates a class, complete with variables and access functions, and calls on 6 other macro's to do the job?

I have seen code like this. Some macro's are very simple. Some macro's are very long, complex pieces of code.

Plus VA does not automatically know which macro to use, consider the code:

#ifdef DEBUG
#define FELINE_MACRO // form 1
#else
#define FELINE_MACRO // form 2
#endif


For now have you considered using VA's rename refactoring?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000