By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,166 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

Replacement for #pragma comment(exestr, "this is a string")?

P: n/a
/COMMENT has been removed from the linker that comes with VS2005, and
use in source code of:

#pragma comment(exestr, "this is a string")

gives the message:

warning LNK4224: /COMMENT is no longer supported; ignored

and doesn't put the string in the exe file.

Has anyone found a replacement for this feature? I've just wasted time
due to someone compilinq an old version which could have been found
immediately with this facility.

Chris

Apr 25 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 25 Apr 2006 10:45:53 -0700, ch*********@postmaster.co.uk wrote:
/COMMENT has been removed from the linker that comes with VS2005, and
use in source code of:

#pragma comment(exestr, "this is a string")

gives the message:

warning LNK4224: /COMMENT is no longer supported; ignored

and doesn't put the string in the exe file.

Has anyone found a replacement for this feature? I've just wasted time
due to someone compilinq an old version which could have been found
immediately with this facility.
I use a compiler flag:
/v
This embeds the string in whatever obj file is being built. The linker
leaves these strings, so they end up in the executable. (I had never
really checked, so working on this note was a good prod for me;
thanks.)


Chris


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com
Apr 25 '06 #2

P: n/a

r_z_aret@pen_fact.com wrote:
On 25 Apr 2006 10:45:53 -0700, ch*********@postmaster.co.uk wrote:
/COMMENT has been removed from the linker that comes with VS2005, and
use in source code of:

#pragma comment(exestr, "this is a string")

gives the message:

warning LNK4224: /COMMENT is no longer supported; ignored

and doesn't put the string in the exe file.

Has anyone found a replacement for this feature? I've just wasted time
due to someone compilinq an old version which could have been found
immediately with this facility.


I use a compiler flag:
/v
This embeds the string in whatever obj file is being built. The linker
leaves these strings, so they end up in the executable. (I had never
really checked, so working on this note was a good prod for me;
thanks.)


Chris


Thanks for the suggestion (it's capital V BTW). It works, but gives the
warning:

cl : Command line warning D9035 : option 'V' has been deprecated and
will be removed in a future release

Why are M$ so against this elementary QA feature?

That aside, I can't see a simple way of including a version number or
date with each object file of a project using /V. With exestr it was
all edited in the C file.

Other ideas appreciated.

Chris

Apr 25 '06 #3

P: n/a
ch*********@postmaster.co.uk wrote:
r_z_aret@pen_fact.com wrote:
On 25 Apr 2006 10:45:53 -0700, ch*********@postmaster.co.uk wrote:

/COMMENT has been removed from the linker that comes with VS2005, and
use in source code of:

#pragma comment(exestr, "this is a string")

gives the message:

warning LNK4224: /COMMENT is no longer supported; ignored

and doesn't put the string in the exe file.

Has anyone found a replacement for this feature? I've just wasted time
due to someone compilinq an old version which could have been found
immediately with this facility.


I use a compiler flag:
/v
This embeds the string in whatever obj file is being built. The linker
leaves these strings, so they end up in the executable. (I had never
really checked, so working on this note was a good prod for me;
thanks.)
Chris

Thanks for the suggestion (it's capital V BTW). It works, but gives the
warning:

cl : Command line warning D9035 : option 'V' has been deprecated and
will be removed in a future release

Why are M$ so against this elementary QA feature?

That aside, I can't see a simple way of including a version number or
date with each object file of a project using /V. With exestr it was
all edited in the C file.

Other ideas appreciated.


You can either add a string as a resource or declare some const string variable.

--
677265676F727940346E6575726F6E732E636F6D
Apr 26 '06 #4

P: n/a


"Grzegorz WrĆ³bel" wrote:
ch*********@postmaster.co.uk wrote:
r_z_aret@pen_fact.com wrote:
On 25 Apr 2006 10:45:53 -0700, ch*********@postmaster.co.uk wrote:
/COMMENT has been removed from the linker that comes with VS2005, and
use in source code of:

#pragma comment(exestr, "this is a string")

gives the message:

warning LNK4224: /COMMENT is no longer supported; ignored

and doesn't put the string in the exe file.

Has anyone found a replacement for this feature? I've just wasted time
due to someone compilinq an old version which could have been found
immediately with this facility.

I use a compiler flag:
/v
This embeds the string in whatever obj file is being built. The linker
leaves these strings, so they end up in the executable. (I had never
really checked, so working on this note was a good prod for me;
thanks.)

Chris

Thanks for the suggestion (it's capital V BTW). It works, but gives the
warning:

cl : Command line warning D9035 : option 'V' has been deprecated and
will be removed in a future release

Why are M$ so against this elementary QA feature?

That aside, I can't see a simple way of including a version number or
date with each object file of a project using /V. With exestr it was
all edited in the C file.

Other ideas appreciated.


You can either add a string as a resource or declare some const string variable.

--
677265676F727940346E6575726F6E732E636F6D


I have found that some linkers remove the static char version string because
it is not referenced. I build the same source code with several
compilers/linkers and I have found that the best solution so far (other than
#pragma comment) is to pass the static char version string as a parameter to
an inline function that returns a pointer to the string... kind of a kludge
but it forces the linkers (all that I have tried so far) to link the static
char into the exe.

This goes into each module:
static char *RCSinfo_filename_ext = MyVersion( "my text version" );

This goes into a common header file that is included in each module:
__inline CHAR *MyVersion( CHAR *versionStr )
{
return( versionStr );
} /* MyVersion */

May 24 '06 #5

P: n/a

SCWoods wrote:
"Grzegorz Wróbel" wrote:
ch*********@postmaster.co.uk wrote:
r_z_aret@pen_fact.com wrote:

>On 25 Apr 2006 10:45:53 -0700, ch*********@postmaster.co.uk wrote:
>
>
>>/COMMENT has been removed from the linker that comes with VS2005, and
>>use in source code of:
>>
>>#pragma comment(exestr, "this is a string")
>>
>>gives the message:
>>
>>warning LNK4224: /COMMENT is no longer supported; ignored
>>
>>and doesn't put the string in the exe file.
>>
>>Has anyone found a replacement for this feature? I've just wasted time
>>due to someone compilinq an old version which could have been found
>>immediately with this facility.
>
>I use a compiler flag:
>/v
>This embeds the string in whatever obj file is being built. The linker
>leaves these strings, so they end up in the executable. (I had never
>really checked, so working on this note was a good prod for me;
>thanks.)
>
>
>
>>Chris
Thanks for the suggestion (it's capital V BTW). It works, but gives the
warning:

cl : Command line warning D9035 : option 'V' has been deprecated and
will be removed in a future release

Why are M$ so against this elementary QA feature?

That aside, I can't see a simple way of including a version number or
date with each object file of a project using /V. With exestr it was
all edited in the C file.

Other ideas appreciated.


You can either add a string as a resource or declare some const string variable.

--
677265676F727940346E6575726F6E732E636F6D


I have found that some linkers remove the static char version string because
it is not referenced. I build the same source code with several
compilers/linkers and I have found that the best solution so far (other than
#pragma comment) is to pass the static char version string as a parameterto
an inline function that returns a pointer to the string... kind of a kludge
but it forces the linkers (all that I have tried so far) to link the static
char into the exe.

This goes into each module:
static char *RCSinfo_filename_ext = MyVersion( "my text version" );

This goes into a common header file that is included in each module:
__inline CHAR *MyVersion( CHAR *versionStr )
{
return( versionStr );
} /* MyVersion */


I too had found that the linker optimises out unused strings and had
considered fooling it with a function call. However I'm surprised it
doesn't optimise out your unused code as well, and I expected to have
to use an extern function.

I'm currently experimenting with the "Comments" field in a resource
file associated with the whole program, but I've yet to fully automate
its updating. I don't know how/whether you can embed a resource in each
C file as Grzegorz's post implies. The advantage of the resource file
method is that you can see the list of modules in right
click/Properties/Version on the exe file instead of having to use a
string extractor. One problem is that it doesn't seem to be possible to
force a newline in the "Comments", so the display looks odd.

Chris

May 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.