主题 : 求助 6410 同一套代码 通过宏命令 分开编译的问题 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 83239
精华: 0
发帖: 9
金钱: 45 两
威望: 9 点
贡献值: 0 点
综合积分: 18 分
注册时间: 2012-12-04
最后登录: 2014-12-05
楼主  发表于: 2014-12-05 09:14

 求助 6410 同一套代码 通过宏命令 分开编译的问题

我把Tiny6410 装成linux系统,
使用虚拟机(Fedora9)交叉编译程序,编程程序使用QT4.7;

现在的情况是:
1、我有一套代码,现在可以编译通过在ARM板上运行, 现在我需要把这一套代码 运行到linux系统上,但是因为代码中有一些库包是掉用的ARM板上的,所以在linux版本中需要注释掉,我想通过宏命令来解决这个问题;求帮忙;

代码如下,我想在编译ARM版本的时候,这部分代码自动编译,在编译LINUX版本的时候,这部分代码自动不编译;

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <errno.h>
#include <string.h>
#include <termio.h>
级别: 骑士
UID: 5844
精华: 9
发帖: 64
金钱: 770 两
威望: 154 点
贡献值: 9 点
综合积分: 308 分
注册时间: 2009-05-11
最后登录: 2019-05-14
1楼  发表于: 2014-12-07 14:32

 回 楼主(a136035905) 的帖子

#ifdef   __ONLY_IN_LINUX__
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/fs.h>
#include <errno.h>
#include <string.h>
#include <termio.h>
#endif


gcc -D__ONLY_IN_LINUX__   XXX.c