Collection of one-file C/C++ libraries with no dependencies, primarily for games
github.com
github.com
https://github.com/RandyGaul/cute_headers/blob/755849fc2819d...
I fixed this exact problem in a highly used library in high energy physics:
https://gitlab.cern.ch/CLHEP/CLHEP/-/commit/5f20daf0cae91179...
Many believe the C++ compiler will magically optimize the switch away, but in some cases, like the example above for CLHEP, it doesn't happen, so you end up with bad performance.
https://github.com/RandyGaul/cute_headers/blob/755849fc2819d...
See an optimized quaternion multiplication implementation in SSE by me here:
https://stackoverflow.com/questions/18542894/how-to-multiply...
I'm sure I've also spotted him in the SDL channels.
Header-only libraries are static linking.
That's fine though. AFAIK, there is no sane way (across platforms) to have singletons, and that involves some of the the trick above, unless you know someother way
If you do, please add your idea here - https://github.com/open-telemetry/opentelemetry-cpp/issues/2... - "Header only singletons are not working properly for Windows #2534"
I'm always suspicious of "Professional" in descriptions like this as it is a meaningless word you add to make it sound impressive.
Also, in this case it means a 900 line math library with 78 lines of tests...
The fact that invert_safe() isn't actually safe isn't the greatest look here though.
Microsoft really does not want you to do this, but they still allow it.
For what it's worth, as someone who primarily writes C, not C++, I use the system package manager, vendoring, and sometimes Git submodules, depending on the project. On Windows, when I'm using MSYS2, I use the pacman package manager. If I'm targeting MSVC, I use CMake. For CMake, on Windows, I create my own directory where I place prebuilt dependencies for CMake to find [1]. With this approach, I can rely on CMake's builtin find_package behavior (no need for vcpkg and configure-time toolchain flags).
[1] https://cmake.org/cmake/help/latest/command/find_package.htm...
It's the same problem with putting build system files into your library source distribution - which build system to pick?
Libraries that come as a header, or a small number of headers and source files have none of those problems because they are trivial to integrate without requiring package manager or build system magic.
E.g. only top level projects should pick a specific build system and package manager, but not libraries.
Just this month I saw yet another sufferer of the consequences of disparate build systems. This resulted in a mixture of GCC and LLVM, which disagreed on the basic ABI for C enums for unknown/none-platform ARM. (ARM's ABI gives multiple options, leaving the choice of which option to use to the platform ABI... which for unknown/none is obviously missing.)
While I consider single-header libs overkill for my own taste in authoring things, I can't deny their continued ease of use in consumption. They're still useful. Sadly. If only because it won't be yet another source of debugging and fixing on my part when coworkers less familiar with integrating 3rd party dependencies into "our" build system either mess things up, or foist that work onto me - introducing delays and reducing bus factor.
For example, the answer to "how do we build this on architecture X?"... should not be install 28000 source files, and wait 3 days to discover half of the packages broke the build... because fork you that's why. lol =3
Stuff like this (lol I don't know a single serious C++ project using conan/vcpkg/etc), or that mojo has replaced all of Python/C/C++ (not will replace but has!), or that Rust has replaced C/C++, or the LLMs have obviated everything.
I have no clue how someone can both be so clueless and yet so sure.
who did i call a name?
The Dunning-Kruger effect also applies to smart people. You don't stop when you are estimating your ability correctly. As you learn more, you gain more awareness of your ignorance and continue being conservative with your self estimates.
My own take on this:
I think real intelligence by definition requires humility. One has to realize that we can't know the things we don't know, which includes the fact that we can't always trust our own beliefs and opinions because we might be relying on faulty or incomplete information, or we might be suffering from a mental health problem, whether we are aware of it or not.
"As a rule, strong feelings about issues do not emerge from deep understanding." -Sloman and Fernbach
nah it's just gossip. they read something spicy about C++ or Mojo or LLMs and they jump at the chance to repeat it.