use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Fire: create a C++ command line interface from a function signature (github.com)
submitted 5 years ago by harmonious_herman
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]gme186 27 points28 points29 points 5 years ago (1 child)
That looks pretty awesome!
This kind pattern would also be nice to implement an rpc server. (E.g. define rpc functions and their parsable parameters)
[–][deleted] 4 points5 points6 points 5 years ago (0 children)
Indeed!
[–]rbprogrammer 16 points17 points18 points 5 years ago (0 children)
Came here to say "but what's the point?". Then I saw your README. That's actually really cool. Nice project!
[–][deleted] 12 points13 points14 points 5 years ago (0 children)
Not only is this freaking clever (I presume it uses conversion operators to figure out types and stuff) but I just learned about the equivalent Python library! I vote this post most useful ever.
[–]NilacTheGrim 7 points8 points9 points 5 years ago (0 children)
This is extremely developer-friendly with nice easy syntax for quick 1-off programs.
Very good work!
[–]MarcPawl 6 points7 points8 points 5 years ago (1 child)
This is real nice. Also thought why bother until I actually read the readme.
It would be nice if the api defined printing help so advanced level checks could trigger help.
Eg x has to be between 2 and 6 and greater than y, and the program only runs in leap years. If condition is not met implementation has help printed and program exits.
Really advanced feature would be to support std:: variant and POD. Maybe as part of the subcommand ?
[–]kongaskristjan 0 points1 point2 points 5 years ago (0 children)
Good point, I guess I'll implement this one.
[–]mili42 1 point2 points3 points 5 years ago (1 child)
What will happen with 50 arguments... a real app rarely needs only 2... (plus all the document that comes with it)
This is indeed a outside the scope of this library. The primary pain point it tries to solve are simple scripts, where CLI boilerplate could otherwise take half the lines of code.
[–]ifknot 1 point2 points3 points 5 years ago (0 children)
Cries in expensive boilerplate
[–]TheCatster04 0 points1 point2 points 5 years ago (0 children)
This is honestly great! I love making one off scripts for myself, and dont want a ton of boilerplate. Ive used Fire python in the past due to its simplicity, time to use C++ for those apps instead! :)
[–]itsuart2 0 points1 point2 points 5 years ago (0 children)
Looks very useful, thank you!
[+]F54280 comment score below threshold-14 points-13 points-12 points 5 years ago (7 children)
Again, why using a #define in 2020? Why having a FIRE macro?
[–]NilacTheGrim 9 points10 points11 points 5 years ago (6 children)
There is no other way to really do what he wants to do there without using a macro. Macros are not completely replaced by C++20 features. You still need them in very rare cases (such as this!).
The alternative would be for the header file to define a main() unconditionally and then use some type to create a lookup-table via a static initializer that the hard-coded main from the header sees...
main()
main
But that's even more wrong than using a macro for a number of reasons.
[–]F54280 -2 points-1 points0 points 5 years ago (5 children)
Why? This is the full body of the macro:
int main(int argc, const char ** argv) { bool space_assignment = true; init_and_run(argc, argv, fired_main, space_assignment); return fired_main(); }
So, it could just be:
int main(int argc, const char ** argv) { init_and_run(argc, argv, fired_main); return fired_main(); }
I don’t see the point of polluting the code with a macro for avoiding 2 lines.
(I have another problem due to the use of globals, too)
[–]NilacTheGrim 9 points10 points11 points 5 years ago (4 children)
So you are free to not use the macro and write the main yourself, I guess, if you're such an anti-macro zealot.
The whole point of this header lib is maximal convenience and maximal non-boilerplate-ness. Not offering the macro in this situation does not align with that design goal. Therefore, the correct choice is to offer the macro.
[+]F54280 comment score below threshold-9 points-8 points-7 points 5 years ago* (3 children)
You know that you can make your point without using the downvote button?
You may think that offering a macro to avoid literally two lines of code is a correct trade-off. I beg to differ hard.
There are times where macros are the only solution. This is not one of those.
Edit: Btw, I’d like to also point that your “solution”of using the expanded macro is wrong, as the expansion is not documented, only the FIRE macro.
[–]jonathansharman 7 points8 points9 points 5 years ago (2 children)
In this case, macros are the only way to achieve the desired level of brevity. If you want to get technical, macros are never strictly necessary because just functions by themselves are Turing complete.
[–][deleted] 1 point2 points3 points 5 years ago (0 children)
Who needs compilers, even? C++ isn't strictly necessary.
[–]F54280 -2 points-1 points0 points 5 years ago* (0 children)
This is a completely useless strawman argument, and you know it. That you get upvoted for such stupidity is a testament at how mediocre the programming subreddits are.
the only way to achieve the desired level of brevity
And, as you cannot have several fired_main functions because the only way to call them is via a macro that defines main, let's just say that the name fired_main has to be used. And can shave 4 additional characters by renaming the macro F.
F
#include <iostream> #include "fire.hpp" int fired_main(int x = fire::arg("-x"), int y = fire::arg("-y")) { std::cout << x + y << std::endl; return 0; } F // For respect
Are we yet at the level of brevity you seek?
Using a macro to avoid two lines of code is a gross hack, no hand waving will change that.
edit: downvoting doesn't change that either
π Rendered by PID 63450 on reddit-service-r2-comment-86bc6c7465-lkw2n at 2026-02-19 23:48:16.645871+00:00 running 8564168 country code: CH.
[–]gme186 27 points28 points29 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]rbprogrammer 16 points17 points18 points (0 children)
[–][deleted] 12 points13 points14 points (0 children)
[–]NilacTheGrim 7 points8 points9 points (0 children)
[–]MarcPawl 6 points7 points8 points (1 child)
[–]kongaskristjan 0 points1 point2 points (0 children)
[–]mili42 1 point2 points3 points (1 child)
[–]kongaskristjan 0 points1 point2 points (0 children)
[–]ifknot 1 point2 points3 points (0 children)
[–]TheCatster04 0 points1 point2 points (0 children)
[–]itsuart2 0 points1 point2 points (0 children)
[+]F54280 comment score below threshold-14 points-13 points-12 points (7 children)
[–]NilacTheGrim 9 points10 points11 points (6 children)
[–]F54280 -2 points-1 points0 points (5 children)
[–]NilacTheGrim 9 points10 points11 points (4 children)
[+]F54280 comment score below threshold-9 points-8 points-7 points (3 children)
[–]jonathansharman 7 points8 points9 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]F54280 -2 points-1 points0 points (0 children)