Skip to content

Header files

Alexandre Gautier edited this page Aug 26, 2016 · 1 revision

Function prototypes

All your function prototypes must be declared in header files.

/* this prototype has to be declared in a header file */
void sample_func(int);

Structs, Enum, Unions definitions

All your structs, enums and union must be defined in header files.

struct sample_struct
{
	int val;
	char *str;
};
enum sample_enum
{
	FIRST = 1,
	SECOND,
	THIRD
};

and

union color
{
	unsigned int ui32_value;
	unsigned char[4] rgba;
};

Typedefs

All your typedefs must be defined in header files.

typedef unsigned char uchar;

typedef struct sample_struct
{
	int value;
	char *str;
} sample_struct;

Double inclusion

To prevent double inclusion, we expect you to protect your header files by defining a macro, only if the header file hasn't been included yet.

Example for a file named sample_header.h:

#ifndef _SAMPLE_HEADER_H_
#define _SAMPLE_HEADER_H_

/*
 * Structs, enums and unions definitions
 * Typedefs
 * Function prototypes
 */

#endif /* _SAMPLE_HEADER_H_ */

0. Betty cli

0.1 - Betty-style usage

0.2 - Betty-doc usage

0.3 - References

1. Coding style

1.1 - Indentation

1.2 - Breaking long lines and strings

1.3 - Placing Braces

1.4 - Placing Spaces

1.5 - Naming

1.6 - Functions

1.7 - Commenting

1.8 - Macros and Enums

1.9 - Header files

2. Documentation

2.1 - Functions

2.2 - Data structures

3. Tools

3.1 - Emacs

3.2 - Vim

3.3 - Atom

Clone this wiki locally