首页 > 其他 > 详细

Makefile宏定义

时间:2014-12-26 13:00:25      阅读:275      评论:0      收藏:0      [点我收藏+]
起因:阅读linux0.11代码时,发现RAMDISK这个宏定义在makefile中。以前没有接触过这种用法,练习一下。


目的:在Makefile中定义的宏,在C语言代码里面使用。


Makefile的内容:


CC=gcc


RAMDISK = -DRAMDISK=512


all:
$(CC) $(RAMDISK)  hello.c
clean:
rm -f a.out
-------------------------------------------------------------------
hell.c


#include <stdio.h>


int main(void)
{
#ifdef RAMDISK

printf("RAMDISK = %d\n", RAMDISK);

#else
printf("NO RAMDISK\n");
#endif
return 0;


总结,其实就是给gcc添加参数

Makefile宏定义

原文:http://blog.csdn.net/yinming4u/article/details/42169961

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!