这个问题可能很简单,但我不找到确切的答案..什么是此行的shell脚本做
在shell脚本我有这样一条线,
export CFLAGS=" -w -Iinc/ -Isrc/"
我不知道-w
和-I
选项在这里做什么?
我所知道的是这条线包括目录inc
和src
任何帮助将是巨大的
这个问题可能很简单,但我不找到确切的答案..什么是此行的shell脚本做
在shell脚本我有这样一条线,
export CFLAGS=" -w -Iinc/ -Isrc/"
我不知道-w
和-I
选项在这里做什么?
我所知道的是这条线包括目录inc
和src
任何帮助将是巨大的
这只是设置一个环境变量。我猜测它已经习惯了为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.
他们争论到您的编译器。如果GCC,则:
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
古茹的巨大飞跃:-)