* Fixed some uncritical stuff in Makefile and some header files.
authorUrban Wallasch <urban.wallasch@freenet.de>
Tue, 30 Jul 2019 16:25:50 +0000 (18:25 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Tue, 30 Jul 2019 16:25:50 +0000 (18:25 +0200)
Makefile
log.h
telemetry.h

index b3b391ea1f4103f57041311772a6b84bb701af81..2756cf511a2164300f21dc558a8f3d94fcb6f0a4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ SDK_INCLUDES=\
   -Isdk/include/eurotrucks2
 
 CFLAGS=-Wall -Wextra -std=c99 -O2 -DDEBUG -I.
-CPPFLAGS=-Wall -O2 -DLOGGING -I.
+CXXFLAGS=-Wall -O2 -DLOGGING -I.
 
 UNAME:= $(shell uname -s)
 
@@ -24,20 +24,23 @@ else
   LIB_NAME_OPTION=-soname
 endif
 
+COMMON_HDR := telemetry.h
 PLUGIN_SRC := teleshmem.cpp shmget.c
+HTTPD_OBJ  := telehttpd.o shmget.o net.o fserv.o
+LOGGER_OBJ := telelogger.o shmget.o
 
 .PHONY: all clean
 
 all: telehttpd telelogger teleshmem.so
 
-teleshmem.so: $(PLUGIN_SRC) $(SDK_HEADERS)
-       g++ -o $@ $(CPPFLAGS) -fPIC --shared -Wl,$(LIB_NAME_OPTION),$@ $(SDK_INCLUDES) $(PLUGIN_SRC)
+teleshmem.so: $(PLUGIN_SRC) $(COMMON_HDR) $(SDK_HEADERS) $(SELF)
+       $(CXX) -o $@ $(CXXFLAGS) -fPIC --shared -Wl,$(LIB_NAME_OPTION),$@ $(SDK_INCLUDES) $(PLUGIN_SRC)
 
-telehttpd: telehttpd.o shmget.o net.o fserv.o
-       $(CC) $(LDFLAGS) -o $@ -pthread $^
+telehttpd: $(HTTPD_OBJ) $(COMMON_HDR) $(SELF)
+       $(CC) $(LDFLAGS) -o $@ -pthread $(HTTPD_OBJ)
 
-telelogger: telelogger.o shmget.o
-       $(CC) $(LDFLAGS) -o $@ $^
+telelogger: $(LOGGER_OBJ) $(COMMON_HDR) $(SELF)
+       $(CC) $(LDFLAGS) -o $@ $(LOGGER_OBJ)
 
 %.o: %.c $(SELF)
        $(CC) -c $(CFLAGS) -o $*.o $*.c
diff --git a/log.h b/log.h
index 9b27875473713c8d438ba02395aa7807a55d6df2..d6398db94601b3c3f024b62dee87a506bd970c28 100644 (file)
--- a/log.h
+++ b/log.h
@@ -8,15 +8,25 @@
 #ifndef LOG_H_
 #define LOG_H_
 
-#ifdef DEBUG
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+
+#if defined DEBUG && !defined __cplusplus
        #define EPRINT(fmt, ...) do { fprintf( stderr, "%s:%s:%d:"fmt, __FILE__, __FUNCTION__, __LINE__ , ##__VA_ARGS__ ); } while (0)
        #define DPRINT(...) EPRINT(__VA_ARGS__)
-       #define WHOAMI DPRINT("\n");
+       #define WHOAMI DPRINT("\n")
 #else
        #define EPRINT(fmt, ...) do { fprintf( stderr, fmt, ##__VA_ARGS__ ); } while (0)
        #define DPRINT(...)
-       #define WHOAMI 
+       #define WHOAMI
 #endif
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* LOG_H_ */
+
index e29db93db9066f17282f719b7e5a5ac40274a9d7..f8859961acf017fc90f589a95857132255d3ba49 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef TELEMETRY_H_
 #define TELEMETRY_H_
 
+#include <stdbool.h>
+#include <stdint.h>
+
 #define TELE_SHM_KEY 0xecc11
 
 struct telemetry_state_t {