majerle / c-code-style Goto Github PK
View Code? Open in Web Editor NEWRecommended C code style and coding rules for standard C99 or later
Home Page: http://majerle.eu
License: MIT License
Recommended C code style and coding rules for standard C99 or later
Home Page: http://majerle.eu
License: MIT License
Hey! I think this is a great style guide and as I'm reading through it I'm going "yep, yep, yep" as I agree with nearly all of it. I intend to adopt a few of these too like the prv_ idea. A few things though:
What is wrong with first curly bracket on the next line?
Not initialising variables to 0? In places I've worked, uninitialised variables will fail your peer review.
Declaring all variables at the top of a block is a bit old fashioned.
I think it's nicer to underscore de-limit function names and camel-case variables. void my_func(void); int32_t myVar = 0;
I agree strongly with documenting #if/#elif/#else/#endif statements. Oh my god this helps so much!
I tried using the astyle-code-format.cfg file with style but it almost only fixes indents and braces. I like the rules you described for variable and function naming but I couldn't find a way to format my C files according to that. There is no such option in AStyle. So even if I use your cfg file with AStyle, there is no difference between using yours or a predefined XML file on Eclipse (like original K&R etc.)
This project has no LICENSE
file at its root.
Technically I believe this makes it your intellectual property, and others that find it shouldn't assume you're willing to share it... I'm no lawyer, but if this were a software project, it wouldn't be OSS without a license.
I'm assuming you're happy for people to share and use this for their own projects openly... either way, if your intent for this standard is:
open
: an open license is necessary for people to use it legallyclosed
: a license stating that you'd like to be contacted before it's copied would also be helpful to those that find it.Many IDE and editors use clang-format to format code, like VSCode, Clion, Visual Studio, QtCreator.
clang-format style docs: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: GNU
may help
Functions:
-> When function returns pointer, asterisk character must be aligned to return type (char*), example for "ok" and "wrong" is the same.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.