papermario
papermario copied to clipboard
Move everything out of functions.h/variables.h
functions.h and variables.h have always been a temporary measure to make it quicker to match stuff. They define a ton of random functions and variables that should really be declared elsewhere.
The ~~not-yet-enabled~~ warnings -Wimplicit -Wredundant-decls described in #366 are relevant here too, as they will enforce good use of header files.
Additionally, we should move all declarations out of .c files and into .h files.
Steps to migrate functions from functions.h:
- Pick a C file with nonstatic functions you'd like to make a header for
- Create a header file (
.h) next to the C file with an include guard - Add an
externdeclaration for global variables defined in the C file (usually marked withgat the start of the variable name) - Add a declaration for every non-static function in the C file
- Remove declarations from
functions.handvariables.h - Add a
#include "myfoo.h"to every file that uses variables or functions declared in your header
Include guard example
#ifndef _MYFOO_H_
#define _MYFOO_H_
// ...
#endif
If we reenable clang-tidy we should be able to automatically shout about declarations that aren't in headers