2010-09-24 76 views
0

这个问题可能很简单,但我不找到确切的答案..什么是此行的shell脚本做

在shell脚本

我有这样一条线,

export CFLAGS=" -w -Iinc/ -Isrc/" 

我不知道-w-I选项在这里做什么?

我所知道的是这条线包括目录incsrc

任何帮助将是巨大的

回答

2

这只是设置一个环境变量。我猜测它已经习惯了为GCC设置标志。

man gcc

-I dir 
     Add the directory dir to the list of directories to be searched for 
     header files. Directories named by -I are searched before the 
     standard system include directories. If the directory dir is a 
     standard system include directory, the option is ignored to ensure 
     that the default search order for system directories and the 
     special treatment of system headers are not defeated . 

    -w Suppress all warnings, including those which GNU CPP issues by 
     default. 
0

他们争论到您的编译器。如果GCC,则:

  • -w:禁止所有警告消息。
  • -I:将目录dir添加到要搜索头文件的目录列表中。在标准系统包含目录之前搜索由'-I'命名的目录。如果目录dir是一个标准系统包含目录,则忽略该选项以确保系统目录的默认搜索顺序和系统标头的特殊处理没有失败(请参阅系统标题)。
0

CFLAGS是一个环境变量的名称。它被设置为值-w -Iinc/ -Isrc/(最初的空间是无用的,所以是斜杠,顺便说一句)。

这个影响C编译器编译的机制是通过make程序。该make工具默认使用此规则编译C程序的目标文件:

.c.o: 
    $(CC) $(CFLAGS) -c $< 

和进口使从可变$(CFLAGS)环境变量$CFLAGS(它们是不同的;不要混淆“ EM)。

你可以阅读所有关于make变量,就http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html

规则及其默认值启蒙试试这个:创建一个空的Makefile,将熟悉helloworld.c在同一个目录,然后键入make helloworld。怎么了?为什么?如果你明白这一点,你已经迈向成为make古茹的巨大飞跃:-)