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
 Feature Requests
 sorting "chunks" of text by first line in chunk
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

msew
Ketchup Master

94 Posts

Posted - Feb 26 2004 :  03:58:17 AM  Show Profile

so you have the wonderful redundent include guards.

Now you want to alphabatize them. Pain ensues. Can you Visual Assist have a pattern that looks for this type of structure and then sorts by the first line?

#ifndef _NAMESPACE_CLASSNAMEARRRR_H_
#include "ClassNameArrr.h"
#endif

LarryLeonard
Tomato Guru

USA
1041 Posts

Posted - Feb 26 2004 :  09:26:39 AM  Show Profile
I've actually been thinking about whether I need guard defines anymore; I doubt I'll ever port anything I've ever written (MFC stuff, anyway) to a compiler that doesn't support #pragma once. Just for my own curiosity, when are you finding that #pragma once won't work, and you need guard defines?
Go to Top of Page

willdean
Tomato Guru

134 Posts

Posted - Feb 26 2004 :  12:11:43 PM  Show Profile

To msew:

I don't think I understand what you're asking for here - include guards are normally *inside* header files, not around the #include itself.

If you put them inside a header file, you only ever have one at once.

Like Larry says, if you're writing inherently non-portable stuff (like MFC) code, then '#pragma once' is faster and easier.

Much of my code needs to compile on multiple compilers, most of which don't support #pragma once, so I still add them manually - but I still don't understand the 'alphabatize' [sic] bit.

I would like a feature in VA which autmatically added the subject of the #if as a comment to after the #endif - so that you get:

#if wibble

#endif // wibble

for a bit less typing...




Go to Top of Page

LarryLeonard
Tomato Guru

USA
1041 Posts

Posted - Feb 26 2004 :  12:29:56 PM  Show Profile
Well, I mean, sometimes you have to do what msew wants if you're trying to guard someone else's header file, and you don't want to modify it... but from the name ClassNameArrr, I assumed it was one he authored himself.

The alphabetizing thing he wants I think would work like this. Say you have 35 'wibble'-type #ifndef blocks, for files ranging from '_AARDVARK_WIBBLE' to "_ZEBRA_WIBBLE', but not in any order. He wants to be able to sort those blocks. That would be pretty hard to generalize, I'm thinking.

Also, I agree that it would be a nice feature for VA to "autmatically" add #endif comments. (The urge to type [sic] is almost overwhelming - instead I'll point you to some freeware: www.iespell.com I love it.)
Go to Top of Page

Stephen
Tomato Guru

United Kingdom
781 Posts

Posted - Feb 26 2004 :  1:35:07 PM  Show Profile
This suggestion seems to be very specific to msew's particular case.

Stephen Turner
ClickTracks http://www.clicktracks.com/
Winner: ClickZ's Best Web Analytics Tool 2003 & 2004
Go to Top of Page

willdean
Tomato Guru

134 Posts

Posted - Feb 26 2004 :  5:25:20 PM  Show Profile
Thanks Larry, but I don't use IE!

No typo/spelling flame is ever complete without a few of its own...


Go to Top of Page

Cezariusz
Tomato Guru

Poland
244 Posts

Posted - Feb 27 2004 :  05:30:01 AM  Show Profile
willdean: there are also spelling plugins available for Firefox

Cezariusz Marek
https://midicat.net/
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19015 Posts

Posted - Mar 02 2004 :  11:48:39 AM  Show Profile
quote:
Originally posted by msew


so you have the wonderful redundent include guards.



if you have quite a few of these to sort, could you:

use a VS macro to join the three lines for each include into one with the pieces separated by spaces.

now you have a set of lines that VAX should sort correctly

now use a second VS macro to split the lines again. since they are space separated a given number of ctrl+left arrow presses should get you to the right place for the line breaks.

something of a fuss, but i have done similar things with macros in vim on many occasions, and it is a real time saver. worth considering if this is a common problem and the VS macros are up to the job.

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

asmout
Ketchup Master

58 Posts

Posted - Mar 08 2004 :  7:42:10 PM  Show Profile
Willdean,

I think one point of the syntax:

#ifndef INCLUDED_blah
#include "blah.h"
#endif

is that the compiler does not need to open the file "blah.h" to discover that it is not needed. This can (marginally) speed up compilation times (though it is a pain to type). Of course, you must still put the guard _inside_ blah.h as well:

#ifndef INCLUDED_blah
#define INCLUDED_blah

< your code here >

#endif // INCLUDED_blah

Do you know if "#pragma once" has the same file open suppression benefit? I have never tried to compare these two approaches.

Andy
Go to Top of Page

LarryLeonard
Tomato Guru

USA
1041 Posts

Posted - Mar 09 2004 :  03:41:45 AM  Show Profile
quote:
Do you know if "#pragma once" has the same file open suppression benefit?
Yes, it does.
quote:
I have never tried to compare these two approaches.
I recently totally removed about 300 redundant #includes from a total of about 1000. It had no effect on build time (which was about 15 minutes). I would assume that changing guard defines to #pragma once's would have even less effect. But they are easier to type...
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000