|
发表于 2008-6-13 17:45:41
|
显示全部楼层
[duxiaoyu@hnchen ~]$ cat Makefile
all:
rm -f timestamp.c
echo "char DATE[] = \"`date`\";" > timestamp.c
gcc -o test timestamp.c test.c
[duxiaoyu@hnchen ~]$ cat test.c
#include <stdio.h>
extern char DATE[];
int main ()
{
printf("compile timestamp is %s\n", DATE);
return 0;
}
[duxiaoyu@hnchen ~]$ ./test
compile timestamp is 2008年 06月 14日 星期六 01:32:38 CST
[duxiaoyu@hnchen ~]$
方法有点土,不过还能用,你还可以把输出放到头文件里,变成宏定义。 |
|