summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-06-27 14:35:20 -0700
committerGuy Harris <guy@alum.mit.edu>2017-06-27 21:39:12 +0000
commitb8273a1497ce7743fb5a818b70aa88d69a9f2b96 (patch)
treee09e96168b5851c76ae6f48e47a323fbe2d09373
parent6efb73e10c3d4d57fac5a4655ef5d414c5bd35d7 (diff)
downloadwireshark-b8273a1497ce7743fb5a818b70aa88d69a9f2b96.tar.gz
Fix the "don't initialize with non-constant variables" item.
It only applies to variables with static storage duration, i.e. global and static variables. Expand the example of how to do it, to make it a bit clearer. Change-Id: Ie0c473a35a77351dd10d6c9df2c34a39f077fca4 Reviewed-on: https://code.wireshark.org/review/22430 Reviewed-by: Guy Harris <guy@alum.mit.edu> (cherry picked from commit 7321df2a4532d6531eab75f99c5f158ffd90574b) Reviewed-on: https://code.wireshark.org/review/22432
-rw-r--r--doc/README.developer24
1 files changed, 20 insertions, 4 deletions
diff --git a/doc/README.developer b/doc/README.developer
index d7e5a09af1..621393eac3 100644
--- a/doc/README.developer
+++ b/doc/README.developer
@@ -80,13 +80,29 @@ features. The C99 features that can be used are:
variadic macros
-Don't initialize variables in their declaration with non-constant
-values. Not all compilers support this. E.g. don't use
+Don't initialize variables with static storage duration - i.e., global
+or static variables - or objects with aggregate type (arrays and
+structures) in their declaration with non-constant values. Not all
+compilers support this. E.g., if "i" is a static or global variable,
+don't declare i as
+
guint32 i = somearray[2];
-use
+
+declare it as just
+
guint32 i;
+
+and later, in code, initialize it with
+
i = somearray[2];
-instead.
+
+instead. Initializations of non-aggregate variables with automatic
+storage duration - i.e., local variables - with non-constant values is
+permitted, so, within a function
+
+ guint32 i = somearray[2];
+
+is allowed.
Don't use zero-length arrays; not all compilers support them. If an
array would have no members, just leave it out.