Re:Show HN: Add a command-line interface to any C++ program
by ranger_danger on Saturday October 16, 2021 @01:14PM
(#28889411)
Just include that header in a separate C/C++ file that has no other purpose, then you won't have to recompile it every time you change something elsewhere.
[ Parent
| on HN ]
Re:Show HN: Add a command-line interface to any C++ program
by corysama on Saturday October 16, 2021 @01:56PM
(#28889860)
Yeah. "header only" had really caught on because it is a catchy term that is simple to understand.
But, what I really, really wish caught on would be "single cpp file" with the expectation that you are capable of adding a single, self-contained source file to whatever build system you happen to be using.
Re:Show HN: Add a command-line interface to any C++ program
by electroly on Saturday October 16, 2021 @02:44PM
(#28890303)
That's often what "header only" libraries really are -- you create your own .cpp file, define a particular preprocessor symbol, and then include the header which will then produce the implementation in that translation unit. Without the symbol defined you only get the interface, suitable for including in other translation units.