相关疑难解决方法(0)

使用C++在编译时将时间戳嵌入目标代码中

我想执行a printf()来显示上次编译当前正在执行的代码的时间.C/C++是否提供了一个宏,可以让您在编译期间解析为时间戳?

c++ versioning timestamp build

37
推荐指数
4
解决办法
2万
查看次数

如何使用__DATE__和__TIME__预定义的宏作为两个整数,然后stringify?

想要使用__ DATE __和__ TIME __作为整数,以便在编译时为我的代码提供自动化版本.

#define STRINGIZER(arg)     #arg
#define STR_VALUE(arg)      STRINGIZER(arg)

#define DATE_as_int_str useD(__DATE__) // What can be done ?
#define TIME_as_int_str useT(__TIME__) // What can be done ?

#define VERSION 1.4

#define COMPLETE_VERSION STR_VALUE(VERSION) "." DATE_as_int_str "." TIME_as_int_str
Run Code Online (Sandbox Code Playgroud)

并获得COMPLETE_VERSION一个字符串const unsigned char [].

const unsigned char completeVersion[] = ?? COMPLETE_VERSION;
Run Code Online (Sandbox Code Playgroud)

应输出1.4.1432.2234的东西.

其中一个可能的解决方案可能是但不起作用:convert - date -to-unsigned-int

在编译时的上下文中,convertint-date-and-time-string-to-just-integers-in-c 可以参考expand-and-stringification-how-to-get-the-marco-name-not-its-value

c macros predefined-macro

37
推荐指数
5
解决办法
9万
查看次数

标签 统计

build ×1

c ×1

c++ ×1

macros ×1

predefined-macro ×1

timestamp ×1

versioning ×1