[glib: 1/2] docs: Add note on how to check a gboolean condition
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] docs: Add note on how to check a gboolean condition
- Date: Mon, 7 Jan 2019 16:24:06 +0000 (UTC)
commit 94d855fc6dd06e4c6006ec593de5b0b36e6e4b5e
Author: Alistair Thomas <astavale yahoo co uk>
Date: Sat Jan 5 20:59:09 2019 +0000
docs: Add note on how to check a gboolean condition
glib/docs.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
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".
*/
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]