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"
And here's the sourceCode:int run(int argc, char **argv); int main(int argc, char **argv){ return run(argc, argv); }
This is a severely stripped down version of the full project (some 400 header and source files, about 300000 lines of code).Code:#include <iostream> #include "main.h" int run(int argc, char **argv){ std::cout << "Wow! This works?" << std::endl; return 0; }
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?



LinkBack URL
About LinkBacks



CornedBee