Header Ordering

Headers in Libav source file should be ordered by distance with the exception of config.h. Please note that config.h should only be added when you need to have any conditional includes.

Remember to insert one line to space between different groups and keep the groups alphabetically ordered so duplicated lines gets spotted easily.

#include "config.h"

#include <stdint.h>
#include <string.h>

#include "libavutil/mem.h"

#include "libavcodec/internal.h"

#include "avformat.h"

In case you have conditional includes, you should place the # as first character and then leave three spaces after the initial block.

/* correct conditional include */
#ifdef ARCH_ARM
#   include "arm/bswap.h"
#endif

/* wrong conditional includes */
#ifdef ARCH_ARM
#include "arm/bswap.h"
# include "arm/bswap.h"
    #include "arm/bswap.h"
#endif

Finally check that your file contains all the headers it needs, even those that are already included by other files. It is a good idea to run make check to avoid leaving any headers behind.

Notice

Pay extra attention to Windows headers!

windows.h should be included after winsock2.h (if not, it may trigger warnings but not errors), and libavformat internals may include winsock2.h, so check that they are included last when it's the case.