
\documentclass[12pt]{article}
\usepackage[T2A,OT1]{fontenc}
\usepackage[default]{cantarell}
\usepackage[a4paper, top=20mm, bottom=20mm, left=20mm, right=20mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[russian, english]{babel}
\usepackage{tabu}
\usepackage{hyperref}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}
\usepackage{setspace}
\onehalfspacing
\author{Artyom Bologov}
\date{\today}
\title{Procnames Start Lines. But Why?}
\makeatletter
\def\endenv{\expandafter\end\expandafter{\@currenvir}}
\makeatother
\begin{document}
\maketitle

\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{./assets/procnames.png}

Looking at some old Open Source C codebase
(everyone does that, right?)
one can notice a weird convention.
Procedure names and return types are split on two separate lines:

\begin{figure}[h!]\begin{verbatim}
char *
hello(char *you)
{
// ...
}
\end{verbatim}\caption{Weird convention, right?}\end{figure}

Pros of this style are

\begin{enumerate}\item It’s easy to find procedure definition with
\verb|grep|: just search for \verb|/^procname/|.
\item It saves some space for argument list.
Especially when the return type includes qualifiers like \verb|static| and \verb|const|.
Or something like \verb|struct long_struct_name *|
\item K&R did that.
That’s the reason someone on StackOverflow provided, but it’s wrong.
“The C Programming Language” had return type on the same line as procedure name.
But! It also had \verb|main()| starting the line, because it was possible to omit the “obvious” \verb|int| return type.
That might be where the confusion started from.
\end{enumerate}

Another reason, provided by Žarko Asen over email:

\begin{figure}[h!]\begin{quote}
return type, procedure qualifications, template characteristics go on the line above the procedure’s name its easier to distinguish the procedure name from the code when it resides in the beginning of a new line
\end{quote}\caption{Highlighting the visual recognition this style gives (text preserved verbatim)}\end{figure}

Relatively obvious cons are:

\begin{enumerate}\item It splits return type and name on separate lines.
Looking up full prototype of the procedure is harder—one needs to open the file and look at the line above the name.
\item It likely doesn’t match the aesthetic preferences of most programmers and languages.
\end{enumerate}

What I’m about to describe is a well-established synthesis of the two conventions: split and joined.
This synthesis is:

\begin{itemize}\item Let procnames start lines in source (.c) files.
\item But list the whole procedure prototype on one line in header (.h) files.
\end{itemize}

This way, procedure prototype is easy to search for (look for .h files),
while the actual procedure source is equally easy to locate (\verb|/^procname/|).

Not forcing that on anyone, of course.
But... does it make any sense now?

\par\noindent\rule{\textwidth}{0.4pt}
Copyright 2022-2025 Artyom Bologov (aartaka).
Any and all opinions listed here are my own and not representative of my employers; future, past and present.

\end{document}
