C to denote functions

I always adhere to the existing coding rules of any language that I use, and I started making C recently. I noticed that some books display functions with a return value over the rest of the function signature, for example:

int foo(int bar) { ... ... ... } 

I did not see this in other languages ​​that I used. Is this the standard way of representing C functions these days, or is it some old convention that is no longer used at all?

+4
source share
4 answers

This is more about getting things like ctags to work efficiently. Or, having the ability to find the body of the function (rather than any call), simply by searching for lines starting with funcname.

Example: /^funcname

As long as you use any reasonable indentation style, this will be the only place (throughout the code base) where it appears at the very beginning of the line in this way.

+1
source

There are no universal conventions for formatting code in C. Popular styles are called a project (for example, the "Linux kernel") or organization (GNU) or a book (K & R), or such things.

Wikipedia has a list of styles.

+2
source

you can see this in the 1990 indian style guide http://www.cs.arizona.edu/~mccann/cstyle.html .

0
source

This is just a matter of style and mostly habits. The compiler does not care about this. Use a style in which you are comfortable, and something that others easily follow when reading the code.

0
source

All Articles