Qt中实现条件编译
2016-08-12 21:51
281 查看
//test.pro TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG -= qt SOURCES += main.c DEFINES += **Home** #DEFINES += Ultimate include(deployment.pri) qtcAddDeployment()
#include <stdio.h> #ifdef Home #define LOG(s) printf("[%s: %d] %s",__FILE__,__LINE__,s) #else #define LOG(s) NULL #endif #ifdef Ultimate void f() { printf("This is Ultimate version\n"); } #else void f() { } #endif int main(void) { LOG("Enter main...\n"); f(); printf("1.Hi.\n"); printf("2.Hello.\n"); #ifdef Ultimate printf("3.Bye.\n"); printf("4.See U.\n"); #else printf("3.GoodBye.\n"); #endif LOG("Exit main...\n"); return 0; }
输出:
[..\test\main.c: 23] Enter main…
1.Hi.
2.Hello.
3.GoodBye.
[..\test\main.c: 36] Exit main…
若修改test.pro中的
//test.pro ... #DEFINES += Home DEFINES += Ultimate ...
则输出为:
This is Ultimate version
1.Hi.
2.Hello.
3.Bye.
4.See U.
相关文章推荐
- Qt在pro中实现条件编译
- Qt在pro中实现条件编译
- Java中利用package机制实现条件编译
- 利用条件编译实现工程定制版本的自动输出
- JAVA如何实现条件编译(从思路开始)
- java中模仿C++实现条件编译
- VS2010纯静态编译QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
- JAVA中实现条件编译
- VS2008纯静态编译QT4.8.0,实现VS2008编译调试Qt程序,QtCreator静态发布程序
- IE浏览器的条件编译指令和微软的ajax实现
- VS2010 win7 QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
- Flash Builder 条件编译的实现
- 用条件编译实现以下功能:输入一行电报文字
- qt通过pri文件实现预编译处理
- 预处理实现条件编译
- 实现针对不同.net版本的条件编译
- Java中利用package机制实现条件编译
- C语言中借助条件编译实现泛型的效果
- (原创)亲测VS2010纯静态编译QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
- IE浏览器的条件编译指令和微软的ajax实现