assign(3)

assign(3) β€” from the Library Functions Manual πŸ’–

okay bestie, welcome to the assign(3) page, and no cap, this one is a tiny little macro with main character energy. It's giving "assign an integer value, check for truncation" and honestly? iconic.


✨ NAME ✨

assign β€” assign an integer value, check for truncation πŸŽ€


πŸ›  SYNTAX πŸ› 

#include <libowfat/rangecheck.h>

int assign(dest,a);

That's the whole synopsis, bestie. The include is libowfat/rangecheck.h, and the call looks like int assign(dest,a);. Keep it exact, no edits. πŸ’…


πŸ“ DESCRIPTION πŸ“

Okay so here's the tea. If a and dest have the same type, OR if the value of a is representable in the type of dest, then you do dest=a and it returns 0. Slay. That's the success path. ✨

Otherwise, it returns 1. That's the "nope, not happening" path. 😭

Note: This is a macro, so dest does not have to be a pointer. Don't come for me, that's literally what the page says. πŸ’…

πŸ› BUGS πŸ›

Not a bug exactly, but a little chaos you need to know: in the multiplication functions, a return value of 1 signals success and 0 means failure. But in add_of, sub_of and assign, it's the other way around. So 0 is success and 1 is failure. Yes, it's giving inconsistent, and yes, you're valid for being confused. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€


signed off from the Library Functions Manual, page assign(3) β€” the footer doesn't give a version or date, just the page name, so this is the whole vibe πŸ’–πŸ’… periodt