-
Notifications
You must be signed in to change notification settings - Fork 1
Coding Style
alvarocebrian edited this page Dec 20, 2019
·
2 revisions
Here is the coding style to be followed. Please, read this document before start pushing
bool dir_exists(const char path[])
{
// code here
}int function (void)
{
// code here
}First, include system libraries and then project libraries
// System libraries
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
// Project libraries
#include "command.h"
#include "directory.h"
#include "error.h"
#include "common.h"Header files must only include other headers that are used in the header, as part of function declarations or as part of a macro. Other headers that are needed for the implementation of a function, must be included in the corresponding implementation file.
Good include
#ifndef _DIRECTORY_H
#define _DIRECTORY_H
// Part of the declaration
#include <stdbool.h>
bool dir_exists(const char path[]);
#endifBad include
#ifndef _DIRECTORY_H
#define _DIRECTORY_H
// Part of the declaration
#include <stdbool.h>
// Part of the implementation, must be in the implementation file
#include <sys/types.h>
#include <dirent.h>
bool dir_exists(const char path[]);
#endif