Compile critical log writer as C++ 84/223884/6
authorMichal Bloch <m.bloch@samsung.com>
Mon, 3 Feb 2020 11:56:51 +0000 (12:56 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 13 Feb 2020 13:35:35 +0000 (14:35 +0100)
Change-Id: I45bfd0d5fe616f1a338fc04f0c0ec1f15fb61517
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
Makefile.am
configure.ac
src/log-critical/log-critical.cpp [moved from src/log-critical/log-critical.c with 94% similarity]

index fea640b..6f781a3 100644 (file)
@@ -98,13 +98,14 @@ dlogutil_SOURCES = \
 
 libexec_PROGRAMS = dlog-log-critical
 
-dlog_log_critical_CFLAGS = \
+dlog_log_critical_CXXFLAGS = \
        $(AM_CFLAGS) \
+       -std=c++14 \
        -fPIE
 dlog_log_critical_LDFLAGS = \
        $(AM_LDFLAGS) \
        -pie
-dlog_log_critical_SOURCES = src/log-critical/log-critical.c
+dlog_log_critical_SOURCES = src/log-critical/log-critical.cpp
 
 bin_PROGRAMS += dlog_logger
 
index c490f7d..faeee2c 100644 (file)
@@ -9,7 +9,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 PLATFORM_INIT
 
 # Checks for programs.
-dnl AC_PROG_CXX
+AC_PROG_CXX
 AC_PROG_CC
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_LIBTOOL
similarity index 94%
rename from src/log-critical/log-critical.c
rename to src/log-critical/log-critical.cpp
index 7f22d27..8b127aa 100644 (file)
        #define DLOG_CRITICAL_LOGFILE "/var/log/dlog/critical"
 #endif
 
+inline void close_fd(const int *fd) { if (*fd >= 0) close(*fd); }
+
 int main (int argc, char **argv)
 {
        if (argc != 2) // Usage: ./dlog-log-critical "formatted message"
                return EXIT_FAILURE;
 
-       inline void close_fd(const int *fd) { if (*fd >= 0) close(*fd); }
        __attribute__((cleanup(close_fd))) const int fd = open(DLOG_CRITICAL_LOGFILE, O_WRONLY | O_APPEND | O_SYNC);
        if (fd < 0)
                return EXIT_FAILURE;