I use ident tool to extract RCS keyword strings from both source file and compiled file.
It certainly works for source codes, and also works for C compiled output by GCC as well as fortran compiled output by G77.
$ gcc -o c.out test.c
$ ident test.c c.out
test.c:
$Id: 63159761756 $
c.out:
$Id: 63159761756 $
$ g77 -o g77.out test.f
$ ident test.f g77.out
test.f:
$Id: 63159761756 $
g77.out:
$Id: 63159761756 $
The problem is when I use gfortran compiler to compile the fortran code. The ident tool CANNOT find the RCS keyword in the compiled code, and returns nothing!
$ gfortran -o gf.out test.f
$ ident test.f gf.out
test.f:
$Id: 63159761756 $
gf.out:
So, what is wrong with gfortran? Is there any optimization which manipulates the variables, or ident tool is not able to parse the complied output of gfortran anymore?
How can I solve this issue please?
Edit:
Fortran Source Code:
PROGRAM HELLO
CHARACTER*80 ID
ID =
*'@(#)$Id: 63159761756 $'
PRINT '(A)', 'Hello,fortran 77'
Print *, 'ID is ', ID
STOP
END
Use a string constant, as in
You will have to make sure to use it somehow, or it is liable to be removed.
Edit
You have to use it somewhere, in such a way that the compiler cannot see that it is actually useless. The only way that I can see at the moment is a bit of a horrible hack, but anyway...
Here, you tell the compiler with the volatile declaration never to assume that print_it could be false. Works, but more elegant suggestions are welcome.