[wiki] [sites] style: Add info about enums + #defines || sin

From: <git_AT_suckless.org>
Date: Tue, 23 Dec 2014 12:25:04 +0100

commit ca2054920547c502bd77ccc77a585a99bc04cf02
Author: sin <sin_AT_2f30.org>
Date: Tue Dec 23 11:24:51 2014 +0000

    style: Add info about enums + #defines

diff --git a/suckless.org/style.md b/suckless.org/style.md
index dca3359..779cb8d 100644
--- a/suckless.org/style.md
+++ b/suckless.org/style.md
_AT_@ -146,3 +146,16 @@ Handling Errors
 * `return` or `exit` early on failures instead of multiple nested levels
 * Unreachable code should have a NOTREACHED comment
 * Think long and hard on whether or not you should cleanup on fatal errors
+
+Enums vs #define
+----------------
+* Use enums for values that are grouped semantically and #define otherwise.
+
+ #define MAXSZ 4096
+ #define MAGIC1 0xdeadbeef
+
+ enum {
+ DIRECTION_X,
+ DIRECTION_Y,
+ DIRECTION_Z
+ };
Received on Tue Dec 23 2014 - 12:25:04 CET

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:39:55 CEST