When I examine the source code of large programs on github, the first thing I always find before the main function is a long list of preprocessor directives.
Would it break anything if I put everything before the main function into a header file (main.h) and then #include just that header file before the main function?
I would check this myself if I knew how to compile these programs. Unfortunately, it's not as simple as tapping Ctrl+Shift+B in Visual Studio.
You really should #include include files that are required in the files that require them and not try to rely on some other file to #include the necessary files.
> Would it break anything if I put everything before the main function into a header file (main.h)
> and then #include just that header file before the main function?
No, it won't break anything. Though it may make the code slightly less readable (two files to read/maintain instead of one, ideally small, file).
There is a school of thought which suggests that the component containing main() should be a small component responsible for setting program-wide policy (for example, a default handlers for std::bad_alloc or seeding the legacy random number generator if one is used) and then delegating the program logic to other components. In this case, it wouldn't be having a long list of preprocessor directives.
github is the name of the biggest garbage dump in the universe; though it is one in which we can find diamonds if we know where to look for them.