Turn of warnings NVCC During compile time

Hi all,

Is there a way to turn of the warnings during compiling?

I got all sorts of warnings like:

"test.cu", line 108: warning: variable "dx" was declared but never referenced

   float *dx;

          ^

"test.cu", line 109: warning: variable "ysource" was declared but never

          referenced

   float *ysource;

these variables are constants but because there are a lot of warnings… I sometimes want to turn them of, so I get only the errors… Make things a lot easier then to have to look through the warnings to find the error messages :)

I already saw someone posted something like this before but there were no answers so I’ll try it again.

Have a look at gcc attribute overview - what you might be able to use is attribute (unused) :

For instance:

int main(	unsigned long long id __attribute__ ((unused)) ,\

  	unsigned long long argp,\

  	unsigned long long envp __attribute__ ((unused))) {

Ok that sounds OK. But then I need to change all the code. And sometimes i want to see the warnings and sometimes I don’t. I was more looking for a way to just give an option to nvcc as --nowarnings.

That is controlled by the Makefile include NVIDIA_CUDA_SDK/common/common.mk which you would have to manually edit to change the warning levels. Try to play around with this section:

# Warning flags

CXXWARN_FLAGS := \

    -W -Wall \

    -Wimplicit \

    -Wswitch \

    -Wformat \

    -Wchar-subscripts \

    -Wparentheses \

    -Wmultichar \

    -Wtrigraphs \

    -Wpointer-arith \

    -Wcast-align \

    -Wreturn-type \

    -Wno-unused-function \

    $(SPACE)

CWARN_FLAGS := $(CXXWARN_FLAGS) \

    -Wstrict-prototypes \

    -Wmissing-prototypes \

    -Wmissing-declarations \

    -Wnested-externs \

    -Wmain \

# Compiler-specific flags

NVCCFLAGS :=

CXXFLAGS  := $(CXXWARN_FLAGS)

CFLAGS    := $(CWARN_FLAGS)

Something along the following would enable you to control this compile-time

ifeq ($(mywarnings),1)

    (warning flags on)

else

    (warning flags off)

endif

So running ‘make mywarnings=0’ would turn the warnings off.

What if you don’t use the make file included in the SDK but just compile like nvcc -I blablabla more crape -o test test.cu