GNU coding standards
Apparence
Formatage du code
The GNU Coding Standards specify exactly how to format most C programming language constructs. Here is a characteristic example:
int
main (int argc, char *argv[])
{
struct gizmo foo;
fetch_gizmo (&foo, argv[1]);
check:
if (foo.type == MOOMIN)
puts ("It's a moomin.");
else if (foo.bar < GIZMO_SNUFKIN_THRESHOLD / 2
|| (strcmp (foo.class_name, "snufkin") == 0)
&& foo.bar < GIZMO_SNUFKIN_THRESHOLD)
puts ("It's a snufkin.");
else
{
char *barney; /* Pointer to the first character after
the last slash in the file name. */
int wilma; /* Approximate size of the universe. */
int fred; /* Max value of the `bar' field. */
do
{
frobnicate (&foo, GIZMO_SNUFKIN_THRESHOLD,
&barney, &wilma, &fred);
twiddle (&foo, barney, wilma + fred);
}
while (foo.bar >= GIZMO_SNUFKIN_THRESHOLD);
store_size (wilma);
goto check;
}
return 0;
}
Source de la traduction
- (en) Cet article est partiellement ou en totalité issu de l’article de Wikipédia en anglais intitulé « GNU coding standards » (voir la liste des auteurs).
Liens externes
- (en) The GNU Coding Standards on the GNU website
- (en) Eclipse Code Style Formatter for GNU Coding Standards