fixed more warnings and Makefile issues. Should compile on mac now

Former-commit-id: cc10ac99b35ae34ba128642da32f0c9a223cfe31
This commit is contained in:
nathan 2020-06-16 17:54:01 -07:00
parent 83f2d6aa30
commit eaf6bc70a8
8 changed files with 21 additions and 18 deletions

View file

@ -1,12 +1,7 @@
#include "Aircraft.h" #include "Aircraft.h"
static auto now() {
return std::chrono::high_resolution_clock::now();
}
Aircraft::Aircraft(uint32_t addr) { Aircraft::Aircraft(uint32_t addr) {
this->addr = addr; this->addr = addr;
// created = now();
prev_seen = 0; prev_seen = 0;
x = 0; x = 0;

View file

@ -1,6 +1,6 @@
#include "AircraftList.h" #include "AircraftList.h"
static auto now() { static std::chrono::high_resolution_clock::time_point now() {
return std::chrono::high_resolution_clock::now(); return std::chrono::high_resolution_clock::now();
} }

View file

@ -4,7 +4,6 @@
//carried over from view1090.c //carried over from view1090.c
// //
int AppData::setupConnection(struct client *c) { int AppData::setupConnection(struct client *c) {
int fd; int fd;

View file

@ -3,17 +3,17 @@
# sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local
# #
CFLAGS=-O2 -g -Wno-write-strings CXXFLAGS=-O2 -std=c++11
LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx
CC=g++ CXX=g++
all: viz1090 all: viz1090
%.o: %.c %.cpp %.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 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: clean:
rm -f *.o viz1090 rm -f *.o viz1090

6
anet.c
View file

@ -122,7 +122,7 @@ int anetResolve(char *err, char *host, char *ipbuf)
struct sockaddr_in sa; struct sockaddr_in sa;
sa.sin_family = AF_INET; 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; struct hostent *he;
he = gethostbyname(host); he = gethostbyname(host);
@ -168,7 +168,7 @@ static int anetTcpGenericConnect(char *err, char *addr, int port, int flags)
memset(&sa,0,sizeof(sa)); memset(&sa,0,sizeof(sa));
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons((uint16_t)port); 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; struct hostent *he;
he = gethostbyname(addr); he = gethostbyname(addr);
@ -271,7 +271,7 @@ int anetTcpServer(char *err, int port, char *bindaddr)
sa.sin_family = AF_INET; sa.sin_family = AF_INET;
sa.sin_port = htons((uint16_t)port); sa.sin_port = htons((uint16_t)port);
sa.sin_addr.s_addr = htonl(INADDR_ANY); 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"); anetSetError(err, "invalid bind address");
close(s); close(s);
return ANET_ERR; return ANET_ERR;

9
anet.h
View file

@ -39,6 +39,10 @@
#define AF_LOCAL AF_UNIX #define AF_LOCAL AF_UNIX
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
int anetTcpConnect(char *err, char *addr, int port); int anetTcpConnect(char *err, char *addr, int port);
int anetTcpNonBlockConnect(char *err, char *addr, int port); int anetTcpNonBlockConnect(char *err, char *addr, int port);
int anetUnixConnect(char *err, char *path); 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 anetPeerToString(int fd, char *ip, int *port);
int anetSetSendBuffer(char *err, int fd, int buffsize); int anetSetSendBuffer(char *err, int fd, int buffsize);
#ifdef __cplusplus
}
#endif
#endif #endif

View file

@ -428,7 +428,7 @@ extern "C" {
// Functions exported from mode_ac.c // Functions exported from mode_ac.c
// //
int detectModeA (uint16_t *m, struct modesMessage *mm); 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); int ModeAToModeC (unsigned int ModeA);
// //
@ -449,7 +449,7 @@ struct aircraft* interactiveReceiveData(Modes *modes, struct modesMessage *mm);
void interactiveShowData(void); void interactiveShowData(void);
void interactiveRemoveStaleAircrafts(Modes *modes); void interactiveRemoveStaleAircrafts(Modes *modes);
int decodeBinMessage (Modes *modes, struct client *c, char *p); 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); struct stDF *interactiveFindDF (uint32_t addr);
// //

View file

@ -210,7 +210,7 @@ int fixBitErrors(unsigned char *msg, int bits, int maxfix, char *fixedbits) {
int bitpos, offset, res, i; int bitpos, offset, res, i;
memset(&ei, 0, sizeof(struct errorinfo)); memset(&ei, 0, sizeof(struct errorinfo));
ei.syndrome = modesChecksum(msg, bits); ei.syndrome = modesChecksum(msg, bits);
pei = (errorinfo*)bsearch(&ei, bitErrorTable, NERRORINFO, pei = bsearch(&ei, bitErrorTable, NERRORINFO,
sizeof(struct errorinfo), cmpErrorInfo); sizeof(struct errorinfo), cmpErrorInfo);
if (pei == NULL) { if (pei == NULL) {
return 0; // No syndrome found return 0; // No syndrome found