Changeset View
Changeset View
Standalone View
Standalone View
share/man/man9/style.9
Show First 20 Lines • Show All 757 Lines • ▼ Show 20 Lines | .Bd -literal | ||||
if ((four = malloc(sizeof(struct foo))) == NULL) | if ((four = malloc(sizeof(struct foo))) == NULL) | ||||
err(1, (char *)NULL); | err(1, (char *)NULL); | ||||
if ((six = (int *)overflow()) == NULL) | if ((six = (int *)overflow()) == NULL) | ||||
errx(1, "number overflowed"); | errx(1, "number overflowed"); | ||||
return (eight); | return (eight); | ||||
} | } | ||||
.Ed | .Ed | ||||
.Pp | .Pp | ||||
Old-style function declarations look like this: | |||||
.Bd -literal | |||||
static char * | |||||
function(a1, a2, fl, a4) | |||||
int a1, a2; /* Declare ints, too, do not default them. */ | |||||
float fl; /* Beware double vs. float prototype differences. */ | |||||
int a4; /* List in order declared. */ | |||||
{ | |||||
.Ed | |||||
.Pp | |||||
Use ANSI function declarations unless you explicitly need K&R compatibility. | |||||
Long parameter lists are wrapped with a normal four space indent. | Long parameter lists are wrapped with a normal four space indent. | ||||
.Pp | .Pp | ||||
Variable numbers of arguments should look like this: | Variable numbers of arguments should look like this: | ||||
.Bd -literal | .Bd -literal | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
void | void | ||||
vaf(const char *fmt, ...) | vaf(const char *fmt, ...) | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |