The code base I work with is portable across several compilers (MSVC, Borland, VxWorks, Intel IPP, ...). We have been using static chars to add revision keywords to our executables so we can track module revisions in the field.
Recently we changed from using static char to #pragma comment because the Intel IPP linker removed the static chars (not being used, so not needed) from the executable.
We are now moving to Visual Studio 2005 and we have found out that #pragma comment( exestr, "xxx" ) has been removed.
One way around this is to use #pragma comment for the IPP compiler and static chars for all others (use #ifdef to distinguish). This puts a bunch of extra code in each module. Is there a cleaner way to do this that doesn't force me to put the extra code into each module
#ifdef
USE_PRAGMA#pragma comment( exestr, "$Header: r:/mksrcs/code/MyConfig.h 1.15 2006/02/14 22:01:34Z woo30 Dev $" "\n" "$Name: SW_5579_2 $" )
#else
static char RCSinfo_MyConfig_h[] = "$Header: r:/mksrcs/code/MyConfig.h 1.15 2006/02/14 22:01:34Z woo30 Dev $" "\n" "$Name: SW_5579_2 $";
#endif

Replacement for #pragma comment( exestr, "xxx" )
dead1
Intel IPP has its own linker In any case, our linker has this feature called "/include" that you can apply to a symbol and it will keep a reference to the symbol. If the Intel compiler is using our linker or if they have a feature like this, then that may work.
Try that with your static char and see if that does the job. That will allow you to use static chars for all your compilers, and not use #pragma comment.
Thanks,
Romualdas
The linker appears to not like the /include option. Regardless, there is one static char object per module, and there are hundreds of modules, so including each object is a bit much.
I have found that if I use the static char but pass the text through a function call that returns a pointer to the text then the static char object sticks around in the executable. For example, in a header file:
__inline char *MyVersion( char *versionStr )
{
return( versionStr );
}
and then in each module something like:
This is kind of hokey to get around the linker dropping the unused reference, especially since the #pragma comment( exestr, "xxx" ) used to do much the same thing.
Why is it that Microsoft decided to deprecate #pragma comment( exestr, "xxx" ) in the first place
dabro
The other thing you can do is use a version resource in your application. I should have mentioned that in the first posting too, but that's going to be a less portable solution.
I had to dig a bit to find why it was deprecated and apparently its a remnant from an old file format, and with PE there is no good place to store this information. Apparently people used to use the desriptor from the .DEF file in this string, but that description is also now obsolete. Hence using version resources being the recommended Windows mechanism today.
Hope that helps.