Fix cast for clang/clang++ in -c++17 mode, using a C-style cast so it's buildable by plain C users.

Add Makefile.clang
Add regression test for Travis

[#39]
This commit is contained in:
James Bowman 2020-03-06 06:20:38 -08:00
parent a3b2262baf
commit 619625e4f0
3 changed files with 13 additions and 1 deletions

View File

@ -323,7 +323,7 @@ uint8_t i2c_reset(I2CDriver *sd)
int i2c_start(I2CDriver *sd, uint8_t dev, uint8_t op) int i2c_start(I2CDriver *sd, uint8_t dev, uint8_t op)
{ {
uint8_t start[2] = {'s', (dev << 1) | op}; uint8_t start[2] = {'s', (uint8_t)((dev << 1) | op)};
writeToSerialPort(sd->port, start, sizeof(start)); writeToSerialPort(sd->port, start, sizeof(start));
return i2c_ack(sd); return i2c_ack(sd);
} }

11
c/linux/Makefile.clang Normal file
View File

@ -0,0 +1,11 @@
CC=clang
CFLAGS += -I common -Wall -Wpointer-sign -xc++ -std=c++17 # -Werror
all: build/i2ccl
install: all
cp build/i2ccl /usr/local/bin
build/i2ccl: linux/i2c.c common/i2cdriver.c
mkdir -p build/
$(CC) -o $@ $(CPPFLAGS) $(CFLAGS) $^

View File

@ -14,3 +14,4 @@ python -c 'from i2cdriver import I2CDriver'
cd c cd c
make -f linux/Makefile make -f linux/Makefile
make -f linux/Makefile.clang