Closed aotto1968 closed 1 year ago
I think the best course of action is to change the implicit cast in the macro to an explicit cast. The legal values for format
are 0 and 1.
diff --git a/lib/libconfig.h b/lib/libconfig.h
index 5e4eea3..6a2ac52 100644
--- a/lib/libconfig.h
+++ b/lib/libconfig.h
@@ -323,10 +323,10 @@ extern LIBCONFIG_API int config_lookup_string(const config_t *config,
#define /* void */ config_set_default_format(/* config_t * */ C, \
/* short */ F) \
- (C)->default_format = (F)
+ (C)->default_format = (unsigned short)(F)
#define /* short */ config_get_default_format(/* config_t * */ C) \
- ((C)->default_format)
+ ((short)(C)->default_format)
#define /* unsigned short */ config_setting_source_line( \
/* const config_setting_t * */ S) \
@aotto1968 Does this patch solve the issue for you?
Fixed in 935062924d2031de52c5e171cc8ef72cce0785e2
Hi,
I using libconfig in my project and ONE task is to write an API for different languages … Now I figure out a problem with the API function "config_set_default_format"
in libconfig.h this function has the prototype :
and the implementation as macro :
but the "short" parameter is in real "unsigned short"
and my "automatic" generated API fails to compile.
just to be truth, I don't like "unsigned" at all