Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/misc share/misc/style: clarify enum example code



details:   https://anonhg.NetBSD.org/src/rev/989f98d7d797
branches:  trunk
changeset: 363414:989f98d7d797
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Mar 10 22:45:23 2022 +0000

description:
share/misc/style: clarify enum example code

The only purpose of the enum example is to show that enum constants are
written in uppercase.

The previous code could be mistakenly interpreted as requiring each
definition of an enum type to also define a global variable of that
type, and to make the variable name the abbreviated type name.  Even if
the enum type were prefixed with 'typedef', choosing different names for
the tag and the typedef would not be necessary.

To avoid these possible misinterpretations above, remove the variable
name from the declaration.

diffstat:

 share/misc/style |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 73bd7fada735 -r 989f98d7d797 share/misc/style
--- a/share/misc/style  Thu Mar 10 18:13:31 2022 +0000
+++ b/share/misc/style  Thu Mar 10 22:45:23 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.62 2021/03/28 14:28:56 christos Exp $ */
+/* $NetBSD: style,v 1.63 2022/03/10 22:45:23 rillig Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.62 2021/03/28 14:28:56 christos Exp $");
+__RCSID("$NetBSD: style,v 1.63 2022/03/10 22:45:23 rillig Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -151,7 +151,7 @@
 enum enumtype {
        ONE,
        TWO
-} et;
+};
 
 /*
  * Sometimes we want a macro to be conditionally defined for debugging



Home | Main Index | Thread Index | Old Index