npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

errnoname.c

v1.2025.5

Published

errnoname is a C library that lets us get the symbolic name for each errno integer value; mentalisttraceur (2019).

Readme

errnoname - The errno Name Library

errnoname is a C library that lets us get the symbolic name for each errno integer value, by mentalisttraceur.

Usage

Installation

Run:

$ npm i errnoname.c

And then include errnoname.h as follows:

#include "node_modules/errnoname.c/errnoname.h"

You may also want to include errnoname.c as follows:

#ifndef __ERRNONAME_C__
#define __ERRNONAME_C__
#include "node_modules/errnoname.c/errnoname.c"
#endif

This will include both the function declaration and their definitions into a single file.

API

The library has a single function:

char const * errnoname(int)

Pass an errno value in, get back a pointer to a null-terminated string containing the name.

If the errno value does not match a known name, a null pointer is returned. (This intentionally includes errno value 0.)

This function is always thread-safe and reentrant.

This function never sets errno.

Example

Here is a "hello world" with error handling:

#include <errno.h> /* errno */
#include <stdio.h> /* EOF, fflush, fprintf, fputs, stderr, stdout */
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */

#include "errnoname.h" /* errnoname */

int main(int argc, char * * argv)
{
    char const * error_name;

    /* `fputs` and `fflush` return `EOF` for all errors: */
    if(fputs("Hello world\n", stdout) != EOF
    && fflush(stdout) != EOF)
    {
        return EXIT_SUCCESS;   
    }

    /* since `fputs` or `fflush` failed, `errno` should be */
    /* the error from the underlying `write` on most systems: */
    error_name = errnoname(errno);

    /* check if null, which means this `errno` value is unknown: */
    if(!error_name)
    {
        fprintf(stderr, "unknown error number: %d\n", errno);
    }
    else
    {
        fprintf(stderr, "error: %s\n", error_name);
    }
    return EXIT_FAILURE;
}

C Name Collisions

The errnoname.h header will only ever define identifiers whose first nine characters are errnoname or ERRNONAME.

So names like errno_name, errnoName, ErrnoName, or ERRNO_NAME will always remain available for you to use.

Building

Just compile and link errnoname.c as normal.

errnoname.c also has an include guard, so you can use it instead of errnoname.h as a header-only library.

Optimization

If errnoname.c is compiled with the ERRNONAME_SAFE_TO_USE_ARRAY preprocessor macro defined, it will use an array of errno names indexed by errno values instead of a switch statement. Your compiler must support designated initializers for this to work.

Note that modern compilers can already automatically convert the switch to an array lookup when optimizations are turned up high enough if it is safe and more efficient to do so.

Contributing

The best way to help this library is making sure that we have the best coverage of errno names possible:

  • Check if the for-maintainers/gather-errno-names.sh script has the most complete and up-to-date sources of information for errno names - maybe you know a better way to get the latest ones for some system, and maybe we are missing a source we should include.

  • Check if the for-maintainers/errno-list.txt file is missing any errno names that you know about.

  • Check if the for-maintainers/generate-c.sh script file handles all errno names that alias the same errno value on any system.

You can also help by sharing your use-cases, what features you want, and design suggestions - the errnoname function is a good minimal foundation, but there might be other features or performance optimizations worth doing.

ORG