我使用 ident 工具从源文件和编译文件中提取 RCS 关键字字符串。
它当然适用于源代码,也适用于 GCC 的 C 编译输出以及 G77 的 fortran 编译输出。
$ 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 $
问题是当我使用 gfortran 编译器编译 fortran 代码时。ident工具在编译后的代码中找不到RCS关键字,什么也不返回!
$ gfortran -o gf.out test.f
$ ident test.f gf.out
test.f:
$Id: 63159761756 $
gf.out:
那么,gfortran 有什么问题呢?是否有任何优化来操纵变量,或者 ident 工具不再能够解析 gfortran 的编译输出?
请问我该如何解决这个问题?
编辑:
Fortran 源代码:
PROGRAM HELLO
CHARACTER*80 ID
ID =
*'@(#)$Id: 63159761756 $'
PRINT '(A)', 'Hello,fortran 77'
Print *, 'ID is ', ID
STOP
END