Closed massix closed 5 years ago
This answers #15, good! I was thinking about using boost::program_options
for parsing command line, though.
Despite the fact that I love boost libraries I kind of dislike adding it as a dependency for a project with a tiny C++ core like mcc.
The boost developers have a funny versioning system and you might often fall in non backward compatible changes between two sibling versions thus forcing you to freeze the current version in order to avoid serious migraines to other contributors and this might lead in a more sophisticated and complicated build system.
There's also a site that keeps track of all the non-backward compatible changes they're introducing, and that thing is scary. :8ball:
One could also argue that boost.program_options has just a dependency on boost.system and they will hardly screw that up since it's the very core of all the derived libraries, but who knows?
After all you are the maintainer and the final choice is yours, it depends on whether you want to keep mcc's core tiny and easily portable or you want to extend it enough to justify boost as a strong dependency.
In any case, thanks a lot for this project, it's hilarious and it's the best way I've found so far to teach some Italian to my French colleagues :-D
That's a good point, I never considered how Boost risks breaking compatibility twice a year. In all seriousness, I didn't think boost::program_options
would be a large dependency, but I understand and totally second your concerns about portability. Another possibility I am evaluating is getopt
/getopt++
.
That said, your code looks good to me. Only, I'd rather avoid rewriting yet another command line parsing library.
I see your point.
I've never used getopt++ personally but we could give it a try.
Another thing I'm thinking, somewhat related to #17 is that if we want MCC to feel and behave like a real compiler, the option -i
is probably unnecessary: when you're using gcc the input files are all the `free' arguments.
v2.0 supports the usual -o
option, among others, without using Boost or other external dependencies. This should fix the issue. Feel free to reopen otherwise.
Hello, in order to have mcc feel like a real compiler, some program options have to be parsed. I've added a facility to do it, in a simple and portable way (among UNIX systems, not sure about Windows though) and started testing using the "-i" and "-o" flags. Everything is working fine so far.
Both input and output provided
Only input (output on stdout by default)
Only output (input on stdin by default)
Let me know if something feels weird (the parsing might be a little bit too basic?). Adding a
--help
option should be easy enough, just by tweaking the Option class in order to accept a boolean value and pretty printing the descriptions of all the options.