Chinaunix首页 | 论坛 | 博客
  • 博客访问: 423780
  • 博文数量: 86
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 822
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-25 10:36
文章分类

全部博文(86)

文章存档

2022年(1)

2021年(3)

2020年(1)

2019年(9)

2018年(24)

2017年(20)

2016年(20)

2015年(8)

我的朋友

分类: C/C++

2018-09-26 21:19:03

If you don't mind changing your source file just once, add something like this:
    const volatile static char version[] = VERSION;

and compile with:  
    gcc -c -DVERSION='"1.2.3"' 

The volatile keeps gcc from removing the string at higher optimization levels.
As written, this won't compile if you forget the -D option, which may be either good or bad depending on your requirements.
阅读(696) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~