Author |
Topic |
|
FlintZA
New Member
South Africa
8 Posts |
Posted - Oct 03 2007 : 05:32:24 AM
|
Is there any way to utilise Visual Studio macros within autotext code? Specifically, I am trying to automatically generate text which includes the project name and the VS $(ProjectName) macro would do the trick. Alternatively, is there another way to access the project name? |
|
bugfix
Tomato Guru
Germany
324 Posts |
Posted - Oct 03 2007 : 08:54:56 AM
|
depending what you're trying to do a way might be to use projects' preprocessor settings. like _PROJECTNAME=$(ProjectName)
-bugfix |
http://www.mf-sd.de |
|
|
FlintZA
New Member
South Africa
8 Posts |
Posted - Oct 03 2007 : 09:10:09 AM
|
I suppose a better description may have helped :) We use an autotext script that generates our comment block and header guard for .h files based on the filename. I have run into a situation where two headers in different libraries have the same name (valid in this case) and while I can differentiate the header files themselves due to their location the guards end up being the same so only the first file's content gets handled:
/Core/PlatformSpecifics.h:
/* File header comment */
#ifndef _PlatformSpecifics_h__
#define _PlatformSpecifics_h__
namespace core
{
// Code
}
#endif // _PlatformSpecifics_h__
/UserInterface/PlatformSpecifics.h:
/* File header comment */
#ifndef _PlatformSpecifics_h__
#define _PlatformSpecifics_h__
namespace userinterface
{
// Code
}
#endif // _PlatformSpecifics_h__
In another file:
#include <Core/PlatformSpecifics.h> // Ok, everything gets included
#include <UserInterface/PlatformSpecifics.h> // Broken, guards prevent anything from being included
I want to prefix the project/library name to the file name in guards to prevent this in future. I can obviously do it manually in the couple of cases it may arise, but I'd prefer save myself the pain of tracking down a silly mistake like same-name headers while in deadline groggyness :)
Unfortunately the above solution doesn't quite work in this case. I considered using a GUID macro, but that seems a bit dirty to me. |
|
|
bugfix
Tomato Guru
Germany
324 Posts |
Posted - Oct 03 2007 : 12:27:56 PM
|
guess you have to stick w/ smth like __$GUID_STRING$_$FILE_BASE$_h__ or write some VS macro to do the job. |
http://www.mf-sd.de |
|
|
hotzenplotz
Senior Member
Austria
34 Posts |
Posted - Oct 03 2007 : 2:16:56 PM
|
Well, I just used a custom "VAX macro" in the autotext entry, that way VAX asks me what to put there when I use the autotext. Like this:
#ifndef INCLUDED_$INCLUDE_GUARD_NAME$
... It would be more comfortable if VAX could put something meaningful there itself, but since I have very specific wishes about what $INCLUDE_GUARD_NAME$ should be, this is probably the best way for me. |
Use the source, Luke!
|
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - Oct 03 2007 : 3:07:26 PM
|
You could do something like this to get the filename from VA - then you can enter a custom prefix (or not):
#ifndef $prefix$$FILE_BASE$_h__ #define $prefix$$FILE_BASE$_h__
$selected$
#endif // $prefix$$FILE_BASE$_h__
|
|
|
sean
Whole Tomato Software
USA
2817 Posts |
|
FlintZA
New Member
South Africa
8 Posts |
Posted - Oct 04 2007 : 02:24:58 AM
|
Thanks for the suggestions. I do already use the FILE_BASE keyword just without the prefix. I'll consider the guid and prompt options. It's a real pity about not using the VS macros.. feature request forums here I come :) |
|
|
mwb1100
Ketchup Master
82 Posts |
Posted - Oct 04 2007 : 12:00:02 PM
|
quote: Originally posted by FlintZA
Thanks for the suggestions. I do already use the FILE_BASE keyword just without the prefix. I'll consider the guid and prompt options.
I used to use a guard something like $FILE_BASE_UPPER$_$FILE_EXT_UPPER$_$GUID_STRING$, but co-workers didn't like it so I had to remove the GUID portion. Now I can point them here and show that the GUID solves a real problem, not just an imaginary one.
Note that GUID_STRING doesn't exactly work because of embedded '-' character, but the snippet gives the idea. |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - Oct 04 2007 : 2:17:16 PM
|
A request for GUID_STRING_ALT (any better name)? |
|
|
FlintZA
New Member
South Africa
8 Posts |
Posted - Oct 05 2007 : 02:42:09 AM
|
quote: but co-workers didn't like it so I had to remove the GUID
That's one of the reasons I'm not too keen on it, I can just see the arguments I'll end up having about it :) |
|
|
|
Topic |
|