We are making a makefile for a class project, and we are having problems with gcc generating .h.gch
files. Looked around on stack overflow and apparently it is normally caused by either including .h
files in dependencies or having something like #include *.cpp
, which we did not do in our makefile.
We get this error when we compile, change a file and compile again. For now we can fix it with make clean
before compiling again, but if possible we'd like to prevent the .h.gch
file from being generated:
avr-gcc -I. -MMD -g -mmcu=atmega324pa -Os -fpack-struct -fshort-enums -funsigned-bitfields -funsigned-char -Wall -fno-exceptions -c pwm.cpp pwm.h interruptNormal.h
cc1: warning: the "stabs" debug format cannot be used with pre-compiled headers [-Wdeprecated]
In file included from pwm.h:5:0:
interruptNormal.h:8:1: error: unknown type name 'class'
class InterruptNormal{
^~~~~
interruptNormal.h:8:22: error: expected '=', ',', ';', 'asm' or '_attribute_' before '{' token
class InterruptNormal{
^
pwm.h:7:1: error: unknown type name 'class'
class Pwm : public InterruptNormal{
^~~~~
pwm.h:7:11: error: expected '=', ',', ';', 'asm' or '_attribute_' before ':' token
class Pwm : public InterruptNormal{
^
cc1: warning: the "stabs" debug format cannot be used with pre-compiled headers [-Wdeprecated]
interruptNormal.h:8:1: error: unknown type name 'class'
class InterruptNormal{
^~~~~
interruptNormal.h:8:22: error: expected '=', ',', ';', 'asm' or '_attribute_' before '{' token
class InterruptNormal{
^
make: * [Makefile:146: pwm.o] Error 1
part of the makefile (not sure how much I could post since we would like to avoid problems with plagiarism):
PRJSRC= $(wildcard *.cpp)
CPPFILES=$(filter %.cpp, $(PRJSRC))
OBJDEPS=$(CPPFILES:.cpp=.o)
%.o: %.cpp
$(CC) $(CFLAGS) $(CXXFLAGS) -c $^
%.hex: %.out
$(OBJCOPY) -j .text -j .data \
-O $(HEXFORMAT) $< $@
Thanks!