This is a sample of a header file:
#ifndef __SAMPLE_H__
#define __SAMPLE_H__
//------------------------------------------------------------------------------
// Include files
//------------------------------------------------------------------------------
#include <stdio.h>
//------------------------------------------------------------------------------
// C++ Compatibility
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
//------------------------------------------------------------------------------
// Global macro definitions
//------------------------------------------------------------------------------
#define SAMPLE_NAME_MAX 128
//------------------------------------------------------------------------------
// Global type definitions
//------------------------------------------------------------------------------
typedef struct sample_node {
int id;
char name[SAMPLE_NAME_MAX];
struct sample_node *next;
} SampleNode;
//------------------------------------------------------------------------------
// Global function declarations
//------------------------------------------------------------------------------
int sample_node_init(SampleNode *node);
//------------------------------------------------------------------------------
#ifdef __cplusplus
} // End of extern "C"
#endif
#endif // __SAMPLE_H__
The __SAMPLE_H__ macro is used to ensure that the header is inluded only once.
The order is important: Function definitions usually require type de finitions, and type definitions usually require macro definitions.
The extern "C" is used for projects that mix C and C++ code. Check this article.