Я пытаюсь скомпилировать простую программу syslog:
#include <syslog.h>
setlogmask (LOG_UPTO (LOG_NOTICE));
openlog ("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
syslog (LOG_NOTICE, "Program started by User %d", getuid ());
syslog (LOG_INFO, "A tree falls in a forest");
closelog ();
, используя только следующую команду:
gcc syslog_1.cpp -o syslog
, но я получил ошибки:
syslog_1.cpp:3:12: error: expected constructor, destructor, or type conversion before ‘(’ token
setlogmask (LOG_UPTO (LOG_NOTICE));
^
syslog_1.cpp:5:9: error: expected constructor, destructor, or type conversion before ‘(’ token
openlog ("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
^
syslog_1.cpp:7:8: error: expected constructor, destructor, or type conversion before ‘(’ token
syslog (LOG_NOTICE, "Program started by User %d", getuid ());
^
syslog_1.cpp:8:8: error: expected constructor, destructor, or type conversion before ‘(’ token
syslog (LOG_INFO, "A tree falls in a forest");
^
syslog_1.cpp:10:12: error: expected constructor, destructor, or type conversion before ‘;’ token
closelog ();
Я запускаю его на Debian Stretch без доступа root (пользователь ssh)