工具/软件:TI C/C++编译器
您好,
我想使用字符串(Linux命令)从可执行文件中获取版本和git信息。
使用GCC时,将以下行添加到源代码时,它可以正常工作。
主要c:
#include <stdint.h>
const char* version_string ="###版本信息-版本0.1 内置(2017年10月09日 11:19:00)_##";
int main (void){
/*
*此处提供一些代码。
*/
}
然后我可以使用:
$字符串my_executable.out | grep "###"
获取版本字符串信息。
但是,当我使用TI编译器编译同一源文件时,目标文件中的字符串将被删除。
当我在某些伪函数中使用变量时,编译器不会删除它,我可以使用字符串获取它,但是我们不需要死代码。
我尝试添加volatile,static,__attribute_((Used )),但这些都没有区别。
我正在使用以下编译标志(来自CCS内部):
-mv7R4 --code_state=32 --float_support=VFPv3D16 -me -off --opt_for _speed=1 --include_path="${CG_tool_root}/include"--include_path="${workspace_loc://${ProjName}/include}"-g --include_path="-symp_tool_root}/include_3=-probiag_probe_3=-type_probnex_abw_-f---refus_jiag_jiag=99_support_ex_exb_ex_support=abw_ex-f_ex-ref-ref-ref_display_support_support_ex_display_ex_support=en_
这些是链接选项,但是由于该字符串也不在目标文件中,我不认为链接程序会引起任何问题。
-m"${ProjName}.map"--heap_size=0x800 --stack_size=0x800 -i"${CG_TOOL_ROOT}/lib"-i${CG_TOOL_ROOT}/include"--reread_libs-diag_wrap=off --display_error_number --warn_sections --xml_proj_info_-xml_model_export.xml_line."-link_off_proj_infection_us_link_off_linuel_link_ex_ex_use.
我正在使用版本v 16.9 .0.LTS。
现在的问题是,我是否可以添加编译/链接标志以防止编译器/链接器删除此变量?
提前感谢:)
Karel