eclipse - C: Implicit declaration of function ‘vsyslog’ -
i trying implement sys logger pam module. code follows:
#define __use_bsd #include <syslog.h> #include <stdarg.h> #include <string.h> static void _log(int level, const char *format, ...) { va_list args; va_start(args, format); openlog("my_app", log_cons|log_pid|log_perror, log_auth); vsyslog(level, format, args); va_end(args); closelog(); } pam_extern int pam_sm_authenticate( pam_handle_t *pamh, int flags,int argc, const char **argv ) { /* something... */ _log(log_info, "username check"); if (strcmp(username, "jdoe") != 0) { _log(log_err, "auth error"); return pam_ignore; } /* else... * } but, when compile, eclipse cdt returns me warning:
../src/mypam.c:33:5: warning: implicit declaration of function ‘vsyslog’ [-wimplicit-function-declaration] how fix it? note using centos 7 dev machine.
fixed, defining both __use_bsd , _bsd_source follows:
#define __use_bsd #define _bsd_source #include <syslog.h> #include <stdarg.h> // ...
Comments
Post a Comment