This new Style rule is made as a part of adding support for NetBSD KNF in clang-format. NetBSD have it's own priority of includes which should be followed while formatting NetBSD code. This style sorts the Cpp Includes according to the priorities of NetBSD, as mentioned in the Style Guide
The working of this Style rule shown below:
Configuration:
This revision introduces a new field under IncludeCategories named SortPriority which defines the priority of ordering the #includes and the Priority will define the categories for grouping the #include blocks.
Here is an example how this Style sorts cpp includes according to NetBSD KNF.
Before Formatting:
#include <sys/param.h> #include <sys/types.h> #include <sys/ioctl.h> #include <net/if_dl.h> #include <net/route.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/wait.h> #include <net/if.h> #include <protocols/rwhod.h> #include <assert.h> #include <paths.h> #include "pathnames.h" #include <errno.h> #include <inttypes.h> #include <stdio.h> #include <stdlib.h>
After Formatting:
#include <sys/param.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/wait.h> #include <net/if.h> #include <net/if_dl.h> #include <net/route.h> #include <netinet/in.h> #include <protocols/rwhod.h> #include <assert.h> #include <errno.h> #include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <paths.h> #include "pathnames.h"