ZT_LOCATION_AT(3)

πŸ’« NAME πŸ’«

zt_location_at β€” the little function that packs a file name and a line number into one single zt_location value πŸŽ€


✨ SYNOPSIS ✨

#include <zt.h>

zt_location
zt_location_at(const char* fname, int lineno);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, zt_location_at takes both of its args and smooshes them together into one zt_location. that's it, that's the whole job πŸ’…

why does it exist tho? because it lets you pack up a zt_claim value without any temporary variables β€” no extra locals cluttering up your function, no cap. it's highkey here to support C compilers that don't do structure literals. so if your compiler is being a little diva about { ... } initializers, this is your girl 🫢

and for conveniently grabbing the current file and line number? use the macro ZT_CURRENT_LOCATION() ✨


πŸ”₯ IMPLEMENTATION NOTES πŸ”₯

  • zt_location_at is only provided as a static inline function. that's the whole vibe, no external symbol, no nothing.
  • the fname argument is retained by the value β€” so it's not copied or anything, the location just holds onto it. and it's typically a constant string literal that the preprocessor handed you. so like, don't go passing it a buffer you're about to free, iykyk πŸ’€

πŸ‘‘ RETURN VALUES πŸ‘‘

a zt_location containing the given file name and line number. literally what you gave it, but packed. slay ✨


🌈 SEE ALSO 🌈


πŸ’– HISTORY πŸ’–

zt_location_at first appeared in libzt 0.1. an icon from the very beginning, periodt.


πŸŽ€ AUTHORS πŸŽ€

Zygmunt Krynicki <me@zygoon.pl> β€” thank you for this absolute gift πŸ™


and that's the whole page bestie!! this one lives in libzt 0.3.1, and it was written down on January 12, 2020. it's a LOCAL manual page, section 3, which is where all the library functions hang out 🧚 go forth and pack your locations πŸ’œ