Reputation: 61
This question may be pretty simple, but i dont find exact answers ..
in shell script i have a line like this,
export CFLAGS=" -w -Iinc/ -Isrc/"
I dont know what is that -w
and -I
options doing here??
All i know is this line includes the directories inc
and src
Any help would be great
Upvotes: 0
Views: 162
Reputation: 72639
CFLAGS
is the name of an environment variable. It gets set to the value -w -Iinc/ -Isrc/
(the initial space is useless, and so are the slashes, btw).
The mechanism how this affects compilation with a C compiler is through the make
program. The make
utility by default uses this rule to compile a C program to an object file:
.c.o:
$(CC) $(CFLAGS) -c $<
and imports the make variable $(CFLAGS)
from the environment variable $CFLAGS
(they are distinct; don't confuse 'em).
You can read all about make
variables, make rules and their default values on http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
For enlightenment try this: create an empty Makefile
, place the familiar helloworld.c
in the same directory and type make helloworld
. What happens? Why? If you understand this, you have made a giant leap towards becoming a make
guru :-)
Upvotes: 0
Reputation: 943569
This just sets an environment variable. I'm guessing that it gets used to set flags for GCC.
From 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.
Upvotes: 2
Reputation: 60902
They're arguments to your compiler. If gcc, then:
Upvotes: 0