Disable function declaration error in avr g++

Sudar picture Sudar · Aug 5, 2012 · Viewed 8.2k times · Source

I am using this Makefile to compile my Arduino sketches which has the following flags for CPP and C

CPPFLAGS      += -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERSION) \
            -I. -I$(ARDUINO_CORE_PATH) -I$(ARDUINO_VAR_PATH)/$(VARIANT) \
            $(SYS_INCLUDES) $(USER_INCLUDES) -g -Os -w -Wall \
            -ffunction-sections -fdata-sections
CFLAGS        = -std=gnu99
CXXFLAGS      = -fno-exceptions

when I compile a cpp file, I am getting a fatal error if the functions are used before they are declared. I went through the avr g++ options and found that the option -Wimplicit-function-declaration enables it. Also it is enabled by the -Wall option, which is used in the make file.

I want to enable -Wall option (since it enables lot of other warnings) but disable only -Wimplicit-function-declaration option.

I checked the documentation, but couldn't figure out how to do this. Can someone kindly tell me how to do it?

Answer

Mat picture Mat · Aug 5, 2012

You can't disable that error when compiling C++ code - it's a fatal error, not a warning.

You can (but shouldn't) get away with it for C code (with -Wno-implicit-function-declaration), but that can't work for C++.

cc1plus: warning: command line option "-Wno-implicit-function-declaration" 
                  is valid for C/ObjC but not for C++