dotconf
dotconf copied to clipboard
Code causes some warnings under -Wall -Wextra
When building dotconf under -Wall -Wextra, there are some warnings caused by dotconf.h:
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:10:2: warning: missing field 'context' initializer [-Wmissing-field-initializers]
LAST_OPTION
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:42:49: note: expanded from macro 'LAST_OPTION'
#define LAST_OPTION { "", 0, NULL, NULL }
^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'configfile' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:47:59: note: expanded from macro 'FUNC_ERRORHANDLER'
#define FUNC_ERRORHANDLER(_name) int _name(configfile_t * configfile, \
^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'type' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:48:16: note: expanded from macro 'FUNC_ERRORHANDLER'
int type, long dc_errno, const char *msg)
^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'dc_errno' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:48:27: note: expanded from macro 'FUNC_ERRORHANDLER'
int type, long dc_errno, const char *msg)
^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:13:1: warning: unused parameter 'msg' [-Wunused-parameter]
FUNC_ERRORHANDLER(error_handler) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:48:49: note: expanded from macro 'FUNC_ERRORHANDLER'
int type, long dc_errno, const char *msg)
^
/Users/sjors/Projecten/dazeus/dotconfbug/main.cpp:35:8: warning: unused parameter 'ctx' [-Wunused-parameter]
static DOTCONF_CB(option) {
^
/Users/sjors/Projecten/dazeus/dotconfbug/dotconf/src/dotconf.h:46:62: note: expanded from macro 'DOTCONF_CB'
context_t *ctx)
^
6 warnings generated.
The main.cpp file is listed in #1 (first comment).
There are some other warnings in dotconf.c itself under both -Wall and -Wall -Wextra, that might need to be looked at/fixed too.
As for the unused parameter references expanded from function macros, these are possibly best fixed by adding some useless variable use in the function, such as adding (void)configfile to the start of the FUNC_ERRORHANDLER. Maybe that can be its own macro: one that "uses" all parameters so that this warning is suppressed if the parameter is not useful.