本文介绍了制作文件CFLAGS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在学习tinyos的过程中,我发现我对makefile完全一无所知.

In the process of learning tinyos I have discovered that I am totally clueless about makefiles.

有许多可选的编译时功能,可以通过声明预处理器变量来使用.

There are many optional compile time features that can be used by way of declaring preprocessor variables.

要使用它们,您必须执行以下操作:

To use them you have to do things like:

CFLAGS="-DPACKET_LINK"这将启用某些功能.

CFLAGS="-DPACKET_LINK" "-DLOW_POWER"启用两个功能.

有人可以帮我剖析这些内容并告诉我发生了什么吗?不是关于tinyos,而是关于makefile!

Can someone dissect these lines for me and tell me whats going on? Not in terms of tinyos, but in terms of makefiles!

推荐答案

CFLAGS是最常用于向编译器添加参数的变量.在这种情况下,它定义宏.

CFLAGS is a variable that is most commonly used to add arguments to the compiler. In this case, it define macros.

因此,-DPACKET_LINK等同于将#define PACKET_LINK 1放在项目中所有.c和.h文件的顶部.最有可能的是,您的项目中有代码可以查看是否定义了这些宏,并根据这些代码执行某些操作:

So the -DPACKET_LINK is the equivalent of putting #define PACKET_LINK 1 at the top of all .c and .h files in your project. Most likely, you have code inside your project that looks if these macros are defined and does something depending on that:

#ifdef PACKET_LINK
// This code will be ignored if PACKET_LINK is not defined
do_packet_link_stuff();
#endif

#ifdef LOW_POWER
// This code will be ignored if LOW_POWER is not defined
handle_powersaving_functions();
#endif

如果在makefile中往下看,应该会看到$(CFLAGS)的用法可能是这样的:

If you look further down in your makefile, you should see that $(CFLAGS) is probably used like:

$(CC) $(CFLAGS) ...some-more-arguments...

这篇关于制作文件CFLAGS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 19:52