Basic coding standard

It's all about the code!
Post Reply
20div0
donator
donator
Posts: 9
Joined: Tue Apr 08, 2014 5:06 pm

Basic coding standard

Post by 20div0 »

I am completely new to this project (but have been a C/C++ programmer for more than 10 years). I was getting familiar with setting up the environment, compiling ...etc. Wanted to play with chibios by itself and noticed there are new versions with a lot of bug fixes. I know it may not affect this codebase but I just want to git the newest version and apply the patch to it. The patch won't apply because the .patch file is using Windows style line endings. It's easy enough to solve by using dos2unix. Looking at the code more, it seems that all the files originally have Unix Style line endings but some recent commits started using Windows style line endings. Now we have mixed Unix and Windows style line endings in the same file. That just made me think if we should put up some simple coding standard for everyone to follow:

1) Unix Style line endings vs Windows Style line endings
2) Tab vs Space
3) CamelCase variable name and function name, with small letter for the first character ... etc
4) Always have { } for if, while ... etc

I am not interested in starting a war (each one of these is enough to start it's own war) but am interested in consistency. I have my own preference but I am willing to follow what gets established.

Andy
User avatar
kb1gtt
contributor
contributor
Posts: 3758
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA

Re: Basic coding standard

Post by kb1gtt »

Have you seen this page http://rusefi.com/wiki/index.php?title=Development:Source_code_intro it needs work, and could have many items like this added to it.

When you say Unix vs windows line endings, I think you mean /n vs /n/r is that correct?

I think this is an item that simply hasn't been really focused on, I don't think anyone would object about making some kind of standard to follow for this kind of item. However I think some will make the code instead of writing a standard. Both are value add operations, but we also need functional code. I've bet formatting and house cleaning patches would be adopted with out any real issues.
Welcome to the friendlier side of internet crazy :)
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Basic coding standard

Post by AndreyB »

These are all legit questions, and good questions and important questions. But...

-1) But right now the biggest question is taking this project off the ground. We are still in a huge chicken or the egg dilemma, the project is too raw for more people to get involved but until more people get involved the project would stay raw :)

Now to your specific questions:
0) We are currently using the latest stable ChibiOS - 2.6.3, the two places of difference are a) __FILE__ into panic messages b) better float support in chvprintf
1) I might guess that ChibiOS source codes were originally Unix, but since all my desktops are Windows I would guess that all my code is Windows. Did not look deeper into that :(

2) Inherited from K&R Eclipse settings, I've just added a page on that: http://rusefi.com/wiki/index.php?title=Development:Code_Style
Image

3) I am a java dev by day. While at start I was using_the_c_notation because everything was C, with the relatively recent addition of C++ I am leaning towards makeItTheWayIAmMoreUsedToo since it looks a hair nicer, at least for C++. I am pretty flexible with that, I know that eventually this would need to be address further, but see #-1.

4) See http://rusefi.com/wiki/index.php?title=Development:Code_Style

Once again, these are great & important questions, I hope that I would not scare you off with a lack of attention to these. It's not the lack of attention - it's the lack of priority caused by the lack of resources.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
20div0
donator
donator
Posts: 9
Joined: Tue Apr 08, 2014 5:06 pm

Re: Basic coding standard

Post by 20div0 »

No, that's fine. I dislike eclipse like others dislike vi. So, I am not sure what the CDT (K&R) really means but I will just follow what's already there.

Andy
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Basic coding standard

Post by AndreyB »

Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
20div0
donator
donator
Posts: 9
Joined: Tue Apr 08, 2014 5:06 pm

Re: Basic coding standard

Post by 20div0 »

Thanks.
Post Reply