The Norm: Mathieu Gaëtan Lytchi
The Norm: Mathieu Gaëtan Lytchi
Version 2.0.0
Mathieu [email protected]
Gaëtan [email protected]
Lytchi [email protected]
II The Norm 3
II.1 Denomination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
II.2 Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
II.3 Functions parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
II.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
II.5 Typedef, struct, enum and union . . . . . . . . . . . . . . . . . . . . . 5
II.6 Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
II.7 Macros and Pre-processors . . . . . . . . . . . . . . . . . . . . . . . . 6
II.8 Forbidden stuff ! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
II.9 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
II.10 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
II.11 Makefile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1
Chapter I
Foreword
I.3 Suggestions
You’ll realise soon enough that the Norm isn’t as intimidating as it seems. On the
contrary, it’ll help you more than you know. It’ll allow you to read your classmates’ code
more easily and vice versa. A source file containing one Norm error will be treated the
same way as a source file containing 10 Norm errors. We strongly advise you to keep the
Norm in mind while coding - even though you may feel it’s slowing you down at first. In
time, it’ll become a reflex.
I.4 Disclaimers
“Norminette” is a program, and all programs are subject to bugs. Should you spot one,
please report it in the forum’s appropriate section. However, as the “Norminette” always
prevails, all your submissions must adapt to its bugs.
2
Chapter II
The Norm
II.1 Denomination
Mandatory part
• A structure’s name must start by s_.
• Variables and functions names can only contain lowercases, digits and ’_’ (Unix
Case).
• Files and directories names can only contain lowercases, digits and ’_’ (Unix Case).
• Characters that aren’t part of the standard ascii table are forbidden.
Advice part
• Objects (variables, functions, macros, types, files or directories) must have the most
explicit or most mnemonic names as possible. Only ’counters’ can be named to your
liking.
• Abreviations are tolerated as long as it’s to shorten the original name, and that
it remains intelligible. If the name contains more than one word, words shall be
separated by ‘_’.
3
The Norm Version 2.0.0
II.2 Formatting
Mandatory part
• All your files must begin with the standard school header (from the first line of the
file). This header is available by default with emacs and vim in the dumps.
• You must indent your code avec with 4-space tabulations. This is not the same as
4 average spaces, we’re talking about real tabulations here.
• Each function must be maximum 25 lines, not counting the function’s own curly
brackets.
• You need to start a new line after each curly bracket or end of control structure.
• Unless it’s the end of a line, each comma or semi-colon must be followed by a space.
• Each operator (binary or ternary) or operand must be separated by one - and only
one - space.
• Each C keyword must be followed by a space, except for keywords for types (such
as int, char, float, etc.), as well as sizeof.
• We cannot stick a declaration and an initialisation on the same line, except for
global variables and static variables.
4
The Norm Version 2.0.0
• You may add a new line after an instruction or control structure, but you’ll have
to add an indentation with brackets or affectation operator. Operators must be at
the beginning of a line.
• A function that doesn’t take arguments must be explicitely pototyped with the
word "void" as argument.
II.4 Functions
Mandatory part
• Parameters in functions’ prototypes must be named.
Advice part
• Your functions’ identifiers must be aligned within a same file. Same goes for header
files.
• When declaring a variable of type struct, enum or union, add a single space in the
type.
• When declaring a struct, union or enum with a typedef, all rules apply. You must
align the typedef’s name with the struct/union/enum’s name.
II.6 Headers
Mandatory Part
• The things allowed in header files are : header inclusions (system or not), declara-
tions, defines, prototypes and macros.
5
The Norm Version 2.0.0
• We’ll protect headers from double inclusions. If the file is ft_foo.h, its bystander
macro is FT_FOO_H.
Advice part
• All header inclusions must be justified in a .c file as well as in a .h file.
◦ for
◦ do...while
◦ switch
◦ case
◦ goto
6
The Norm Version 2.0.0
II.9 Comments
Mandatory part
• You’re allowed to comment your code in your source files.
• Comments start and end by a single line. All intermediary lines must align and
start by ‘**’.
Advice part
• You comments must be in English. And they must be useful.
II.10 Files
Mandatory part
• You cannot include a .c file.
II.11 Makefile
Advice part
• The $(NAME), clean, fclean, re and all rules are mandatory.
• In the case of a multibinary project, on top of the rules we’ve seen, you must have a
rule that compiles both binaries as well as a specific rule for each binary compiled.
• In the case of a project that calls a functions library (e.g.: libft), your makefile
must compile this library automatically.