summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Wilmet <swilmet@gnome.org>2019-12-18 14:25:12 +0100
committerSébastien Wilmet <swilmet@gnome.org>2019-12-18 14:27:26 +0100
commit56e257d255cf30b0f06ecc879ff19d497f11c6ca (patch)
tree281b6c115d82a5322bd7e15b579f407945e1d539
parentb84b964327019b946534a4cd7838b591c1f69a60 (diff)
downloadgtk-doc-56e257d255cf30b0f06ecc879ff19d497f11c6ca.tar.gz
scangobj: fix -Wdouble-promotion warnings
If a project passes the -Wdouble-promotion CFLAG when compiling the generated *scan.c file, then it emits some warnings. For example in the Devhelp project: ``` Building documentation for devhelp-3 devhelp-3-scan.c: In function ‘describe_double_constant’: devhelp-3-scan.c:595:39: warning: implicit conversion from ‘float’ to ‘gdouble’ {aka ‘double’} to match other operand of binary expression [-Wdouble-promotion] 595 | #define GTKDOC_COMPARE_FLOAT(x, y) (x <= y && x >= y | ^~ devhelp-3-scan.c:608:12: note: in expansion of macro ‘GTKDOC_COMPARE_FLOAT’ 608 | else if (GTKDOC_COMPARE_FLOAT (value, G_MAXFLOAT)) | ^~~~~~~~~~~~~~~~~~~~ [...] ``` An example where the -Wdouble-promotion CFLAG is used is with the AX_COMPILER_FLAGS Autotools macro, part of autoconf-archive. ----- In the diff, the `value` variable is of type gdouble.
-rw-r--r--gtkdoc/scangobj.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/gtkdoc/scangobj.py b/gtkdoc/scangobj.py
index 683634a..7434ec1 100644
--- a/gtkdoc/scangobj.py
+++ b/gtkdoc/scangobj.py
@@ -611,11 +611,11 @@ describe_double_constant (gdouble value)
desc = g_strdup ("G_MINDOUBLE");
else if (GTKDOC_COMPARE_FLOAT (value, -G_MAXDOUBLE))
desc = g_strdup ("-G_MAXDOUBLE");
- else if (GTKDOC_COMPARE_FLOAT (value, G_MAXFLOAT))
+ else if (GTKDOC_COMPARE_FLOAT (value, (gdouble)G_MAXFLOAT))
desc = g_strdup ("G_MAXFLOAT");
- else if (GTKDOC_COMPARE_FLOAT (value, G_MINFLOAT))
+ else if (GTKDOC_COMPARE_FLOAT (value, (gdouble)G_MINFLOAT))
desc = g_strdup ("G_MINFLOAT");
- else if (GTKDOC_COMPARE_FLOAT (value, -G_MAXFLOAT))
+ else if (GTKDOC_COMPARE_FLOAT (value, (gdouble)-G_MAXFLOAT))
desc = g_strdup ("-G_MAXFLOAT");
else{
/* make sure floats are output with a decimal dot irrespective of