I am trying to set up syntax checking with flymake and I've got the basic setup working.
My makefile for flymake is simply like follows:
INCLUDES = -I ./inc ## list of more includes omitted for brevity
.PHONY: check-syntax
check-syntax:
gcc -Wall -Wextra -pedantic -fsyntax-only -Wno-variadic-macros -std=c99 $(INCLUDES) $(CHK_SOURCES)
This works ok for my C sources.
Now how to use the same makefile and the same check-syntax target for C++? I can't set multiple -std options like -std=c99 -std=c++98 to the same gcc invocation or can I? Do I need to use some conditional? I can't have multiple check-syntax targets on the same Makefile.
You could split it up into two targets:
Then check the syntax using the C compiler and the C flags in one target, and using the C++ and C++ flags for the other.
Although you have to split up your sources in C and C++ sources, which you should do anyway.
If you don't have the files split already, you can do it using a GNU Make text function named
filter
to split the sources: