Reputation: 77
How to supress -Werror=pointer-to-int-cast
and -Werror=address
kind of errors in Linux?
I know below are options to use for suppressing the above errors.
-Wno-error=address
-Wno-pointer-to-int-cast
But my question is how to use them or where to edit the compiler settings as I am building a large project.
Upvotes: 3
Views: 5896
Reputation: 883
If you are using gcc, consider the following :
You can simply compile your program using :
gcc -o obj src_file
src_file : *.c ( any file name with ".c" extension )
If you are using Makefiles, then
#SRC stands for source file
#OBJ stands for object file
SRC = file.c
OBJ = file
CFLAGS = -Wall # do not include the -Werror flag, otherwise warnings will be
# treated as errors.
$(OBJ) : $(SRC)
gcc $(CFLAGS) -o $(OBJ) $(SRC)
Upvotes: 1
Reputation: 1165
Put them in CFLAGS if you are using a standard Makefile build system.
If it's an autoconf project, put it in Makefile.am like this:
CFLAGS = -Wno-error=address -Wno-pointer-to-int-cast
If you're using some other build system, it needs to be passed to gcc command line when compiling .c files to .o.
If it's an existing package that uses autoconf, you can pass it to ./configure like this:
$ ./configure --extra-cflags='-Wno-error=address -Wno-pointer-to-int-cast'
Other autoconf based projects take it from the environment instead of (or in addition to) --extra-cflags:
$ CFLAGS='-Wno-error=address -Wno-pointer-to-int-cast' ./configure --any-other-options-you-need
Upvotes: 4