summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorAlistair Thomas <astavale@yahoo.co.uk>2019-01-05 20:59:09 +0000
committerAlistair Thomas <astavale@yahoo.co.uk>2019-01-07 15:19:41 +0000
commit94d855fc6dd06e4c6006ec593de5b0b36e6e4b5e (patch)
tree940fb39321abf387791ff42909cccf4d1268b0c6 /glib
parent245279e834cfcde0e07445a879748d08d5e5633b (diff)
downloadglib-94d855fc6dd06e4c6006ec593de5b0b36e6e4b5e.tar.gz
docs: Add note on how to check a gboolean condition
Diffstat (limited to 'glib')
-rw-r--r--glib/docs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/glib/docs.c b/glib/docs.c
index 9e5269236..93decb109 100644
--- a/glib/docs.c
+++ b/glib/docs.c
@@ -64,6 +64,15 @@
* A standard boolean type.
* Variables of this type should only contain the value
* %TRUE or %FALSE.
+ *
+ * Never directly compare the contents of a #gboolean variable with the values
+ * %TRUE or %FALSE. Use `if (condition)` to check a #gboolean is "true", instead
+ * of `if (condition == TRUE)`. Likewise use `if (!condition)` to check a
+ * #gboolean is "false".
+ *
+ * There is no validation when assigning to a #gboolean variable and so it could
+ * contain any value represented by a #gint. This is why the use of `if
+ * (condition)` is recommended. All non-zero values in C evaluate to "true".
*/
/**