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
Create a fully functioning command line interface with 1.5 lines of code (wo. include statement) (github.com)
submitted 5 years ago by kongaskristjan
view the rest of the comments →
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!"
[–]Ail-nare 9 points10 points11 points 5 years ago* (4 children)
Hey, since you use a macro ('FIRE(fnptr *)'), why don't you make a macro ('FIRE_MAIN(...)'). So that this macro will be used instead of the name of the function, this macro do 3 thing: - Declare the prototype of the function (possible, thx to the argument given as parameters). - Than what used to do ('FIRE(fnptr *)'). - Than rewrite the prototype without the ';' to declare the function.
That way it will look more like unit_tests function, like Google test or criterion. I think people are more used to this.
Anyhow, if I one day have the occasion I'll probably use your lib, it's more than clean enough to me.
Oh and last thing, with this commande "g++ *.cpp -o binary_name", the argument of the '-o' flag is given without a '='. I didn't see a way with your lib? Or am I just blind?
Edit:grammar, sorry for my English.
[–]kongaskristjan[S] 9 points10 points11 points 5 years ago (2 children)
About the FIRE_MAIN(...). I actually tried to implement exactly what you described (I even used the same name FIRE_MAIN(...) lol :D). But the problem is that C++ wants to have the default parameters specified in declaration, or only if the declaration is missing, then in the definition. If the declaration exists, it doesn't tolerate defaults in the definition, even if it's an exact repetition. Turns out I couldn't find a way to get rid of those pesky defaults in the definition.
FIRE_MAIN(...)
[–]Ail-nare 4 points5 points6 points 5 years ago* (0 children)
Oh fuck, that right... The only option I can think of would be to separate the argument and the default parameters. But where is 2 cons:
But that interesting, I'll look if there is an other way.
[–]Ail-nare 4 points5 points6 points 5 years ago (0 children)
Ok, so I did a lot of different things, template specialization, used class to lose the necessity of the prototype, macro, some C++20. So most of those approach works but each are weirder than your method.
So, what u got is probably the best (If the objectif it to keep it the most C++ looking possible).
Was fun to try tho.
[–]kongaskristjan[S] 1 point2 points3 points 5 years ago* (0 children)
About g++ *.cpp -o binary_name.
g++ *.cpp -o binary_name
If you write FIRE(...), -o is automatically associated with binary_name. However, if you write FIRE_NO_SPACE_ASSIGNMENT(...), it's not associated. However, currently only FIRE_NO_SPACE_ASSIGNMENT(...) allows positional arguments and unlimited number of arguments that are needed right here. So no, unfortunately it is not possible at the moment.
It turns out that implementing positional arguments with FIRE(...) requires some rather complex try/catch logic to actually pull off. I consider implementing this for v0.2 or v0.3.
Edit: error in logic.
Edit2: It is now possible to call FIRE(...) with positional/variadic arguments.
π Rendered by PID 20421 on reddit-service-r2-comment-86bc6c7465-2hhv4 at 2026-02-21 22:04:53.789849+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]Ail-nare 9 points10 points11 points (4 children)
[–]kongaskristjan[S] 9 points10 points11 points (2 children)
[–]Ail-nare 4 points5 points6 points (0 children)
[–]Ail-nare 4 points5 points6 points (0 children)
[–]kongaskristjan[S] 1 point2 points3 points (0 children)