nothings / single_file_libs

List of single-file C/C++ libraries.
8.86k stars 585 forks source link

Submission: `errnoname` - Public Domain / 0BSD #179

Open mentalisttraceur opened 4 years ago

mentalisttraceur commented 4 years ago

My library errnoname seems like a good fit here.

It is a two-file library: you can grab just errnoname.h and errnoname.c.

It can even be used as a header-only, single-file library by just grabbing and including the errnoname.c file (renamed to errnoname.h if desired), which has an include guard too.

The BSD zero-clause license is equivalent to public domain, just works even in jurisdictions where it is legally impossible to just make our works enter into the public domain, like the United States.

The LICENSE file does not have to be copied along with the code files to use them. (It is there so that GitHub can autodetect the license, and to help people easily see that the whole project is freely available. The full license text is also in each code file, and allows you to use the code even if you remove the license text, copyright header, whatever, just like public domain.)

None of the other files are necessary for using the C code either. (They are for making new versions of the library and so on.)

It is worth sharing here because it is a use case that comes up often enough, and there are programs out there which are harder to reliably script or downright misleading because they didn't do it, partly because it wasn't accessible enough.

Getting the standard symbolic name of an errno value as a string should be a very simple task, but it requires a lot of repetitive lines of code to do, and if you want to cover all the bases like portability, it requires research, even more repetitive lines of code, and other hassle.

errnoname does all that so no one else has to again.