public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* force the (gfortran) compiler to not optimize out a variable
@ 2022-07-28 14:24 David Brown
  0 siblings, 0 replies; only message in thread
From: David Brown @ 2022-07-28 14:24 UTC (permalink / raw)
  To: gcc-help

To be able to easily identify the version of an executable binary, we embed
a version string in the code, i.e.
character(len=64)   :: vers='<<<vers_bltr4_1.1.0.0>>>'//achar(0)
...
character(len=256) c256

and then use the strings command to (we're running redhat) to be able to
quickly identify the version of the executable, i.e.
[db@VI1 src]$ strings ../bin/bltr4.exe | grep "<<<ver"
<<<vers_bltr4_1.1.0.0>>>

The only problem is that to make sure the variable vers does not get
optimized out by the compiler, I have to include code like this
c256=vers    !needed so version string does not get optimized out by
compiler

We do need to make sure the code is optimized, but having to include that
above assignment statement is not only somewhat obtuse but in some edge
cases chews up resources (some of the programs are very time/resource
sensitive).  I've tried various work arounds, but in summary the above
assignment seems to be the only way to insure the compiler does not
optimize out the vers string.

Is there any way to force the compiler to keep a variable in the
executable, yet otherwise have the optimizer on?

Thanks in advance

David





-- 
David Brown
Eckhardt Trading Company
300 S. Wacker Drive, Suite 1080
Chicago, IL 60606
Tel:  312-765-0565 x1006

-- 


PAST PERFORMANCE IS NOT
NECESSARILY INDICATIVE OF FUTURE RESULTS.



This 
message (including
any attachments) contains confidential information 
intended for a specific individual
and purpose and is protected by law. Any 
use, distribution, disclosure, alteration,
copying or re-transmittal by 
persons who are not intended recipients of this
email may be a violation of 
law and is strictly prohibited. If you are not the
intended recipient, 
please permanently delete all copies of this e-mail and any
attachments 
from your computer system and destroy any hard copies. This e-mail
and any 
attachments hereto are for informational purposes only and should not
be 
construed as an offer to provide advisory services, or sell interests in 
any
investment vehicle managed, by the Trading Advisor or its affiliates. 
Any
information regarding trading performance must be considered in 
conjunction
with the appropriate disclosure documents.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-28 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 14:24 force the (gfortran) compiler to not optimize out a variable David Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).