Discussion:
small proposed style change
David Holland
2012-02-19 22:25:21 UTC
Permalink
The style rules should not be suggesting things that no longer
constitute good practices, if they ever did. Any objections?


Index: share/misc/style
===================================================================
RCS file: /cvsroot/src/share/misc/style,v
retrieving revision 1.49
diff -u -r1.49 style
--- share/misc/style 1 Sep 2011 09:33:01 -0000 1.49
+++ share/misc/style 19 Feb 2012 22:23:37 -0000
@@ -331,13 +331,11 @@
/*
* When declaring variables in functions declare them sorted by size,
* then in alphabetical order; multiple ones per line are okay.
- * Function prototypes should go in the include file "extern.h".
- * If a line overflows reuse the type keyword.
+ * Function prototypes and external data declarations should go in a
+ * suitable include file. If a line overflows reuse the type keyword.
*
* DO NOT initialize variables in the declarations.
*/
- extern u_char one;
- extern char two;
struct foo three, *four;
double five;
int *six, seven;
--
David A. Holland
***@netbsd.org
Marc Balmer
2012-02-19 22:28:00 UTC
Permalink
Post by David Holland
The style rules should not be suggesting things that no longer
constitute good practices, if they ever did. Any objections?
yes. Using extern declarations is fine. They don't necessarly need to
go to a separate inlude file.

No objections to the file naming part, though.
Post by David Holland
Index: share/misc/style
===================================================================
RCS file: /cvsroot/src/share/misc/style,v
retrieving revision 1.49
diff -u -r1.49 style
--- share/misc/style 1 Sep 2011 09:33:01 -0000 1.49
+++ share/misc/style 19 Feb 2012 22:23:37 -0000
@@ -331,13 +331,11 @@
/*
* When declaring variables in functions declare them sorted by size,
* then in alphabetical order; multiple ones per line are okay.
- * Function prototypes should go in the include file "extern.h".
- * If a line overflows reuse the type keyword.
+ * Function prototypes and external data declarations should go in a
+ * suitable include file. If a line overflows reuse the type keyword.
*
* DO NOT initialize variables in the declarations.
*/
- extern u_char one;
- extern char two;
struct foo three, *four;
double five;
int *six, seven;
--
\~~~~~. The NetBSD Foundation
\~~~~~' Marc Balmer, Developer / Marketing
NetBSD
\ ***@NetBSD.org http://www.NetBSD.org/
David Holland
2012-02-20 01:34:17 UTC
Permalink
Post by Marc Balmer
Post by David Holland
The style rules should not be suggesting things that no longer
constitute good practices, if they ever did. Any objections?
yes. Using extern declarations is fine. They don't necessarly need to
go to a separate inlude file.
extern declarations of data should always be in header files so
they're shared between the uses and the definition. Otherwise nothing
prevents the definition from being inconsistent with the declaration
seen at the location of use.

And, I shouldn't need to explain this in 2012. :-p
--
David A. Holland
***@netbsd.org
Christos Zoulas
2012-02-20 05:47:37 UTC
Permalink
Post by David Holland
Post by Marc Balmer
Post by David Holland
The style rules should not be suggesting things that no longer
constitute good practices, if they ever did. Any objections?
yes. Using extern declarations is fine. They don't necessarly need to
go to a separate inlude file.
extern declarations of data should always be in header files so
they're shared between the uses and the definition. Otherwise nothing
prevents the definition from being inconsistent with the declaration
seen at the location of use.
And, I shouldn't need to explain this in 2012. :-p
Not only that extern declarations are file scope not function scope.
Remove the code; it is bogus.

christos
Alan Barrett
2012-02-20 05:55:09 UTC
Permalink
Post by David Holland
- * Function prototypes should go in the include file "extern.h".
- * If a line overflows reuse the type keyword.
+ * Function prototypes and external data declarations should go in a
+ * suitable include file. If a line overflows reuse the type keyword.
That looks reasonable to me. As with most other things, there will
sometimes be reasonsto violate the style guide.

BTW, we usually put two spaces after a full stop.

--apb (Alan Barrett)

Loading...