2 by Samuel Fredrickson <kinghajj@gmail.com>
8 This is a simple style guideline for the RPN project. All code in the
9 project must follow these rules, which are subject to change at any time.
11 1. Tabs, Spaces and Alignment
12 -----------------------------
14 Use tabs to indent, spaces to align. No exceptions. This is so that those
15 who prefer 2, 4, or 8 width tabs can see the source in their prefered way
16 without messing up the alignment.
18 Here are some example function declarations. Note that "[tb]" represents a
21 int RPN_hereIsALongFunctionWithSomeSmallParameters(int firstParam,
23 int RPN_andHereIsALongFunctionWithManyLongParameters(int a, double b,
24 RPN_Calculator *calc);
25 int RPN_thisNameIsWayTooLongButIsIncludedJustInCaseItsEverNeeded(
26 [tb]RPNCalculator *calc, RPNValue v);
28 And here's an example definition of a function.
30 int RPN_hereIsALongFunctionWithManyLongParameters(int firstParam,
33 [tb]if(firstParam == secondParam)
34 [tb][tb]RPN_printf("firstParam == secondParam\n");
35 [tb]return firstParam + secondParam;
38 You may also choose to align assignments if it's logical to do so. But
39 again, use spaces to align to keep the alignment portable.
41 2. Curly Bracket Placement
42 --------------------------
44 I prefer the BSD/Allman style, which puts curly brackets on their own line
45 with the same indentation as the control structure or function, but I'm
46 tolerant of the K&R style. The GNU and Pico styles are just ugly.
48 3. Variable Declaration
49 -----------------------
51 Although modern C compilers let you declare a variable anywhere within a
52 function, for this project, declare all variables at the beginning. Writing
53 the variables you think you'll need can help you plan a function, and having
54 all declarations together can make it easier to remove unneeded ones.
59 I write my code to follow the 80-column limit, but I realize that that limit
60 can be reached sooner by those who view code with an 8 width tab, or later
61 by those who use a 2 width tab, so the limit does not need to be followed.
62 Try to stay below 120 columns, though; your code should never need to get