NN_SYMBOL(3)
π 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: theNN_MSGsymbol is not exported by thenn_symbolfunction. 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 indexiwas 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
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- fedora 44: nanomsg-devel 1.2.2-2.fc44 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms