#Searching the C Code Convention
55 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
There is no the C code convention.
You mean best coding practices?
I'm not aware of any resources for that either; it tends to be quite subjective and up to the programmers
https://nullprogram.com/blog/2023/10/08/
This isn't a complete guide that covers all features of the language, but I think it's quite a good style guide
https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html
Complete C guide, and covers all features of the language.
The GNU C Reference Manual
?
Probably not what OP was asking for
that looks close to what im asking for
That C reference manual is literally just a syntax sheet, not a style guide
Syntax is the rules, styles are possible variations within those rules.
yes and in the code conventions it shows some styles and prohibits anything else
i can write
int x = 8,
b =9;
Or
Int x =5;
int b =6;
and it doesnt encourage
int x=4, b=6;
a while statement has only one style.
what else can there be ?
if it shows only one, it excludes anything else
because otherwhise it would mean we would have 1000 styles and everyone can be in a situation to need to learn another style just to understand the code
A C coding standard is a set of rules for source code that is adopted by a team of programmers working together on a project, such as the design of an embedded system.  Programming teams and companies write down their C coding standards for a variety of reasons but often bicker internally about which rules to follow.Barr Group's Embedded C Codin...
that looks like the best ive seen so far
i think i take that
4times the amount of pages as the java convention 😂
yes but they explain their choices using "rationals"
@opal void there are many, I like https://www.kernel.org/doc/html/latest/process/coding-style.html the most
and I mean many competing ones
and to quote very beginning of that document, because someone sent some GNU link (although not for coding convention):
First off, I’d suggest printing out a copy of the GNU coding standards, and NOT read it. Burn them, it’s a great symbolic gesture.
oh, that's horrible, the second example
burn gnu link ?
it looks diffferent
they've sent C compiler manual, but it also containts examples in the shitty convention iirc
but there exists GNU coding convention document as well
ignore it :P
the gnu c-manual explains integere very detailed
Yes, because it's a syntax manual and not a style guide
but earlier you explicitly showed examples on coding style matters
just two completely different things, learning about C and its data types
and learning how to format your code for readability
isnt that included in the code convention ?
for java it looks like this
the gnu c manual looks more detailed
but its even better that way
understanding the tools, Syntax and types
there's no requirement, no official standard, no single style of writing C code
different projects, different styles
there's a core type system in C and that's a part of the standard
unrelated to code formatting
the formatting is a matter of preferences, taste, agreement in project/team
for learning what data types you have you learn C, the C programming language, it is separate from choosing a formatting style
note there are publicly available final drafts of the C standard document (the official final document is paid), but not the best learning material at the beginning