summaryrefslogtreecommitdiff
path: root/glib.h
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-01-21 15:27:39 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-01-21 15:27:39 +0000
commit948f64a183b75de140fd86fefd72b35fda082887 (patch)
treeeb1ada483f08d680217810b7b341305cb84456ec /glib.h
parent9bee3ef88d3b68235a382254c3d3ba712325014c (diff)
downloadglib-948f64a183b75de140fd86fefd72b35fda082887.tar.gz
Added G_N_ELEMENTS macro to determine the number of elements in an array.
Fri Jan 21 10:18:24 2000 Owen Taylor <otaylor@redhat.com> * glib.h (G_N_ELEMENTS): Added G_N_ELEMENTS macro to determine the number of elements in an array.
Diffstat (limited to 'glib.h')
-rw-r--r--glib.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/glib.h b/glib.h
index b94c94540..92397dddb 100644
--- a/glib.h
+++ b/glib.h
@@ -134,6 +134,11 @@ extern "C" {
#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string)
#define G_STRINGIFY_ARG(contents) #contents
+/* Count the number of elements in an array. The array must be defined
+ * as such; using this with a dynamically allocated array will give
+ * incorrect results.
+ */
+#define G_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
/* Define G_VA_COPY() to do the right thing for copying va_list variables.
* glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.