GP32 C Coding Style Guide


Hi.

There should be no rules for Coding Style. Except... Always stick to your own coding style OR to the coding style of the project you're working on...

Just have a look at the indent program under Linux (maybe on other unices too, I dunno) to see a lot of coherent ways to code, with different styles... And this is only about spaces, tabs, line jumps... Not even talking about the naming conventions... About that, pick up a few projects on sourceforge and see: the only rule is to not mix rules!

Anyway a lot of compilers don't like c++ comments in c-code, but most of them have a nice command-line switch to allow them :)

wammy
 
Sure - Unless you've done very little coding before & have no "style" ;)

Beginning programmers tend to "ape" code examples until they develop their own style.
Why not begin with a consistent coding style that is clean, clear & understandable to others ?

It is easier to learn a good habit than un-learn a bad one.

And yeah, The only rule is that there are no rules.
(or Spoons, sorry Neo)
 
I always use two-space indents. Unfortunately F%£$"$"ing MSVC++ likes to default to 4-space tabs and indents every time it's started...luckily in Tools I just found a way to force spaces instead of tabs and default to 2-chars, sweet!

Used to put braces on same line, but I think it looks ugly now, so all braces go on seperate lines. Double-newline between functions. Single-statement IFs have no brackets but are indented (I know, it's wrong). Rather than DoTime (the 'wrong' one) and 'do_time' (the 'right' one) I use doTime, which is nicer, for variables at least. Functions tend to be ProperCase.

I must point out that this guide is for the convenience of the professor of that course, so he can understand the code. As wammy said, it's your style or that of the project. Often unfortunately the API can force certain styles upon you.
 
hugofurst posted on May 15 2003 said:
Sure - Unless you've done very little coding before & have no "style" ;)

Beginning programmers tend to "ape" code examples until they develop their own style.
Why not begin with a consistent coding style that is clean, clear & understandable to others ?

It is easier to learn a good habit than un-learn a bad one.

And yeah, The only rule is that there are no rules.
(or Spoons, sorry Neo)
Hi.

I forgot the case you don't have a stile yet :) Sorry!

This is a good start, but the best is, as I said, to pick up some projects on
sourceforge and see what you're the most comfortable with... You can also
study every mode indent proposes but sometimes this is just like hell :)

wammy
 
Last edited by a moderator:
Back
Top