NN_SYMBOL(3)

πŸ“¦
version 1.2.2 Β· 5 versions
, in fedora 44

πŸ’– NN_SYMBOL πŸ’–

okay bestie, so this is a page from the nanomsg manual (section 3, the library-functions girlies), and it's all about nn_symbol β€” the function that lets you query the names and values of nanomsg symbols. yes, that's literally the whole vibe. let's get into it πŸ¦‹


✨ SYNOPSIS ✨

#include <nanomsg/nn.h>

const char *nn_symbol (int i, int *value);

🌸 DESCRIPTION 🌸

So here's the tea. nn_symbol retrieves the symbol name and value at index i. Indices start at 0. And no, the index does not mean anything about the symbol it's attached to β€” the mappings may literally change between library versions, so do not get attached. it's giving "the vibes shift, the girlies adapt" πŸ’…

Typically a client will iterate through the symbols until nn_symbol returns NULL in order to collect all the symbols. that's the classic move β€” keep going till you hit the void, then stop. periodt.

All symbols exposed by nn_symbol are available directly in the C API, generally as preprocessor macros. So this function is useful mostly for language bindings that can't parse the header file and rely on retrieving the symbols at runtime. iykyk 🧚

⚠️ heads up bestie: the NN_MSG symbol is not exported by the nn_symbol function. two reasons, and they're both valid: - First, it's a pointer rather than an integer. - Second, the symbol is not supposed to be exported from language bindings to the user. Instead, language bindings should provide the zero-copy functionality in a language-specific way β€” if at all. (zero-copy functionality may not make sense for some languages/bindings. it's not for everyone and that's okay 🫢)

πŸŽ€ RETURN VALUE πŸŽ€

If i is valid, returns the name of the symbol at that index. If the pointer value is not NULL, the symbol's value is stored there. cute, functional, efficient ✨

If i is out-of-range, nn_symbol returns NULL and sets errno to EINVAL. heartbreaking but informative. πŸ’€


😭 ERRORS 😭

  • EINVAL β€” The passed index i was out-of-range; it was less than zero or greater-than-or-equal-to the number of symbols. basically you asked for a symbol that doesn't exist. she said no. πŸ™ˆ

πŸ‘‘ EXAMPLE πŸ‘‘

the classic loop, no cap:

int value, i;
for (i = 0; ; ++i) {
    const char* name = nn_symbol (i, &value);
    if (name == NULL) break;
    printf ("'%s' = %d\n", name, value);
}

infinite loop until NULL? main character energy fr fr. πŸ”₯


🌈 SEE ALSO 🌈


πŸ’œ AUTHORS πŸ’œ

Evan Wies <evan@neomantra.net> β€” thank you king, we appreciate you 🫑


okay that's the whole page bestie!! ✨ this one's from nanomsg 1.2.2, dated 2026-01-16. slay, go iterate responsibly. bye πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from