neovim/neovim — pull request #378 by philix (2014-03-17 15:40:30+00:00)
Title: [RDY] Kill structs.h

Moved the defs and typedefs from `structs.h` to specific files. Some of them are new header files:

- eval_defs.h
- mark_defs.h
- memfile_defs.h
- memline_defs.h
- syntax_defs.h
- undo_defs.h

The process I followed to delete `structs.h`:

- Moved most of `structs.h` to the newly created `buffer_defs.h` as most of the types depend on `buf_T` and `win_T`
- Moved the few remaining types in `structs.h` to other headers such as `hardcopy.h`. For this I had to move a global (`printer_opts`) to `hardcopy.c`. This was an opportunity to move a list of `#define`s from `globals.h` to `hardcopy.h`
- Started moving types from `buffer_defs.h` to other header files
- Added `TODO` comments to the very few types that should be moved from `buffer_defs.h` to other headers. I tried moving `alist_T` to `ex_cmds_defs.h`, but this header file is very tricky. There are no header guards because this file is included twice: in the first include it declares the `enum` type of the commands and in the second time it's included `DO_DECLARE_EXCMD` is defined and `cmdnames` is declared. This trick makes it very hard to include `ex_cmds_defs.h` in `buffer_defs.h` (`alist_T` is necessary to define `struct window_S`).

## In favor of self-contained header files

I think we should decide whether header files should be self-contained (i.e. if a header declares functions with the `type_T` type then the header that defines `type_T` should be included). This practice is sometimes controversial, but it is recommended by the C standard [1] and I think we should move in this direction to make it easier to reason about header files.

See **Include all the header files which your header file depends on** in [2].

[1] http://stackoverflow.com/a/1804719/707094
[2] http://guilhermemacielferreira.com/2011/11/16/best-c-coding-practices-header-files/