Sujet : Re: Which code style do you prefer the most?
De : huey.dll (at) *nospam* tampabay.rr.com (David LaRue)
Groupes : comp.lang.cDate : 25. Feb 2025, 16:23:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <XnsB29169B4B7798hueydlltampabayrrcom@135.181.20.170>
References : 1
User-Agent : Xnews/2006.08.24
Ar Rakin <
rakinar2@onesoftnet.eu.org> wrote in
news:vpkmq0$21php$1@dont-email.me:
Hello there,
I've been writing C code for a long time, in different styles, but
always wanted to know which code style most people prefer. This is all
about that question. Which one of the following do you prefer the most?
1. GNU Style
---------
#include <stddef.h>
#include <stdbool.h>
#include "malloc_internals.h"
struct malloc_chunk
{
struct malloc_chunk *next; /* The next chunk. */
struct malloc_chunk *prev; /* The previous chunk. */
bool is_free; /* Whether this chunk is usable. */
size_t size; /* The size of this chunk. */
};
I used a style similar to this in school. Before that I used much the same.
As for existing code bases I prefer to keep their style and add comments
accordingly. That generally goes for any language.
Popularity of a style shouldn't be a goal. It should be consistantly
readable and documented. We must write for ourselves as well as our future
self and others.