This is supposed to compile?
Looking through someone else's source today, I saw something that I previously thought was not possible: a source file without a main function. So I fiddled about with the outline, and it turns out that it does compile.
Here's a header "main.h"
Code:
int run(int argc, char **argv);
int main(int argc, char **argv){
return run(argc, argv);
}
And here's the source
Code:
#include <iostream>
#include "main.h"
int run(int argc, char **argv){
std::cout << "Wow! This works?" << std::endl;
return 0;
}
This is a severely stripped down version of the full project (some 400 header and source files, about 300000 lines of code).
In any case, I'd always assumed that an executable source file had to have a main routine. But it turns out it's not. So what's the general advantage of doing something like this? Would it make a large project more manageable? Or is it just showing off/syntactic sugar?