r/C_Programming • • Jul 10 '26

Question C programming style

Hi all, in my opinion choosing a valid C programming style may help people to maintain code. I know that freedom is a plus, especially for code creators, but it may become a real nightmare for code maintainers.

In my work experience I always tried to keep a uniform code style even if I work by myself, but, after six months I create a software, if I don't use a code style I lose so much time to correct my own code that sometimes I create it newly from scratch.

My question is: are there any places where programmers share their code styles, or some advices (especially variable or typedef names) based upon their real work experience?

Thanks in advance to anyone who will answer! Cheers!

23 Upvotes

24 comments sorted by

View all comments

Show parent comment

2

u/eigenlenk Jul 11 '26

I use this style for functions as well (from: https://suckless.org/coding_style/ )

Haven't worked out how to best format multiple arguments with long types and/or names.

int
myfunction(
  some_long_type_a some_a,
  some_long_type_b some_b,
  etc...
)
{

or

) {

2

u/sirjofri Jul 11 '26

Suckless borrows a lot from Plan 9.

Long types are annoying, and I also didn't find a very good way for that. However, if you have too many arguments, it's sometimes useful to put them in a struct.