From eaf6bc70a815f45fd883a6346f7c6254b0c738f2 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 16 Jun 2020 17:54:01 -0700 Subject: [PATCH] fixed more warnings and Makefile issues. Should compile on mac now Former-commit-id: cc10ac99b35ae34ba128642da32f0c9a223cfe31 --- Aircraft.cpp | 5 ----- AircraftList.cpp | 2 +- AppData.cpp | 1 - Makefile | 10 +++++----- anet.c | 6 +++--- anet.h | 9 +++++++++ dump1090.h | 4 ++-- mode_s.c | 2 +- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Aircraft.cpp b/Aircraft.cpp index 99a2d1c..632115f 100644 --- a/Aircraft.cpp +++ b/Aircraft.cpp @@ -1,12 +1,7 @@ #include "Aircraft.h" -static auto now() { - return std::chrono::high_resolution_clock::now(); -} - Aircraft::Aircraft(uint32_t addr) { this->addr = addr; - // created = now(); prev_seen = 0; x = 0; diff --git a/AircraftList.cpp b/AircraftList.cpp index 03a24cc..dc2e252 100644 --- a/AircraftList.cpp +++ b/AircraftList.cpp @@ -1,6 +1,6 @@ #include "AircraftList.h" -static auto now() { +static std::chrono::high_resolution_clock::time_point now() { return std::chrono::high_resolution_clock::now(); } diff --git a/AppData.cpp b/AppData.cpp index 0bfda44..c2896e7 100644 --- a/AppData.cpp +++ b/AppData.cpp @@ -4,7 +4,6 @@ //carried over from view1090.c // - int AppData::setupConnection(struct client *c) { int fd; diff --git a/Makefile b/Makefile index fb6dc98..33bb980 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,17 @@ # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local # -CFLAGS=-O2 -g -Wno-write-strings -LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -CC=g++ +CXXFLAGS=-O2 -std=c++11 +LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx +CXX=g++ all: viz1090 %.o: %.c %.cpp - $(CC) $(CFLAGS) $(EXTRACFLAGS) -c $< + $(CXX) $(CXXFLAGS) $(EXTRACFLAGS) -c $< viz1090: viz1090.o AppData.o AircraftList.o Aircraft.o anet.o interactive.o mode_ac.o mode_s.o net_io.o Input.o View.o Map.o parula.o monokai.o - $(CC) -g -o viz1090 viz1090.o AppData.o AircraftList.o Aircraft.o anet.o interactive.o mode_ac.o mode_s.o net_io.o Input.o View.o Map.o parula.o monokai.o $(LIBS) $(LDFLAGS) + $(CXX) -o viz1090 viz1090.o AppData.o AircraftList.o Aircraft.o anet.o interactive.o mode_ac.o mode_s.o net_io.o Input.o View.o Map.o parula.o monokai.o $(LIBS) $(LDFLAGS) clean: rm -f *.o viz1090 diff --git a/anet.c b/anet.c index fd31f3d..a425117 100644 --- a/anet.c +++ b/anet.c @@ -122,7 +122,7 @@ int anetResolve(char *err, char *host, char *ipbuf) struct sockaddr_in sa; sa.sin_family = AF_INET; - if (inet_aton(host, (in_addr*)&sa.sin_addr) == 0) { + if (inet_aton(host, &sa.sin_addr) == 0) { struct hostent *he; he = gethostbyname(host); @@ -168,7 +168,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port, int flags) memset(&sa,0,sizeof(sa)); sa.sin_family = AF_INET; sa.sin_port = htons((uint16_t)port); - if (inet_aton(addr, (in_addr*)&sa.sin_addr) == 0) { + if (inet_aton(addr, &sa.sin_addr) == 0) { struct hostent *he; he = gethostbyname(addr); @@ -271,7 +271,7 @@ int anetTcpServer(char *err, int port, char *bindaddr) sa.sin_family = AF_INET; sa.sin_port = htons((uint16_t)port); sa.sin_addr.s_addr = htonl(INADDR_ANY); - if (bindaddr && inet_aton(bindaddr, (in_addr*)&sa.sin_addr) == 0) { + if (bindaddr && inet_aton(bindaddr, &sa.sin_addr) == 0) { anetSetError(err, "invalid bind address"); close(s); return ANET_ERR; diff --git a/anet.h b/anet.h index 6d74af5..7fc84f0 100644 --- a/anet.h +++ b/anet.h @@ -39,6 +39,10 @@ #define AF_LOCAL AF_UNIX #endif +#ifdef __cplusplus +extern "C" { +#endif + int anetTcpConnect(char *err, char *addr, int port); int anetTcpNonBlockConnect(char *err, char *addr, int port); int anetUnixConnect(char *err, char *path); @@ -56,4 +60,9 @@ int anetTcpKeepAlive(char *err, int fd); int anetPeerToString(int fd, char *ip, int *port); int anetSetSendBuffer(char *err, int fd, int buffsize); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/dump1090.h b/dump1090.h index 5e5c21d..a47dba0 100644 --- a/dump1090.h +++ b/dump1090.h @@ -428,7 +428,7 @@ extern "C" { // Functions exported from mode_ac.c // int detectModeA (uint16_t *m, struct modesMessage *mm); -void decodeModeAMessage(Modes *modes, struct modesMessage *mm, int ModeA); +//void decodeModeAMessage(Modes *modes, struct modesMessage *mm, int ModeA); int ModeAToModeC (unsigned int ModeA); // @@ -449,7 +449,7 @@ struct aircraft* interactiveReceiveData(Modes *modes, struct modesMessage *mm); void interactiveShowData(void); void interactiveRemoveStaleAircrafts(Modes *modes); int decodeBinMessage (Modes *modes, struct client *c, char *p); -struct aircraft *interactiveFindAircraft(uint32_t addr); +// struct aircraft *interactiveFindAircraft(uint32_t addr); struct stDF *interactiveFindDF (uint32_t addr); // diff --git a/mode_s.c b/mode_s.c index 16fc27b..c70de6d 100644 --- a/mode_s.c +++ b/mode_s.c @@ -210,7 +210,7 @@ int fixBitErrors(unsigned char *msg, int bits, int maxfix, char *fixedbits) { int bitpos, offset, res, i; memset(&ei, 0, sizeof(struct errorinfo)); ei.syndrome = modesChecksum(msg, bits); - pei = (errorinfo*)bsearch(&ei, bitErrorTable, NERRORINFO, + pei = bsearch(&ei, bitErrorTable, NERRORINFO, sizeof(struct errorinfo), cmpErrorInfo); if (pei == NULL) { return 0; // No syndrome found