Getting the subversion repository number into code

前端 未结 6 379
醉梦人生
醉梦人生 2020-11-30 01:24

I\'d like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number

6条回答
  •  抹茶落季
    2020-11-30 01:50

    in your Makefile, add:

    SVNDEV := -D'SVN_REV="$(shell svnversion -n .)"'
    CFLAGS := $(SVNDEV) ...
    

    then you can use macro SVN_REV anywhere in your code, eg:

    printf ("Version: SVN %s\n", SVN_REV);
    

提交回复
热议问题