Skip to content

Commit

Permalink
Compile the example tests with both a C and C++ compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
aceckel committed Sep 17, 2020
1 parent f8a83d6 commit 78a3743
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.o
tags
test
test++
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ UNAME=$(shell uname)

CCFLAGS=-Wall -Wextra -Wconversion -Wredundant-decls -Wshadow -Wno-unused-parameter -O3
CC=clang
CXX=clang++

all: test
all: test test++

remake: clean all

%.o: %.c ctest.h
%.cpp: %.c
ln -fs $< $@

%.c.o: %.c ctest.h
$(CC) $(CCFLAGS) -c -o $@ $<

test: main.o ctest.h mytests.o
$(CC) $(LDFLAGS) main.o mytests.o -o test
%.cpp.o: %.cpp ctest.h
$(CXX) $(CCFLAGS) -c -o $@ $<

clean:
rm -f test *.o
test: main.c.o ctest.h mytests.c.o
$(CC) $(LDFLAGS) main.c.o mytests.c.o -o test

test++: main.cpp.o ctest.h mytests.cpp.o
$(CXX) $(LDFLAGS) main.cpp.o mytests.cpp.o -o test++

clean:
rm -f test test++ *.o

0 comments on commit 78a3743

Please sign in to comment.