Tcl_SetErrno(3)

πŸ“¦
version 9.0.3 Β· 2 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05

πŸ’– Tcl_SetErrno β€” the manual page, but make it make sense πŸ’–

okay bestie, welcome to the Tcl Library Procedures section of the Tcl manual, and today's main character is Tcl_SetErrno(3). she's a tiny little family of functions whose whole job is to manipulate errno so you can store and retrieve error codes like the icon she is. no cap. 🌸


✨ NAME ✨

Tcl_SetErrno, Tcl_GetErrno, Tcl_ErrnoId, Tcl_ErrnoMsg, Tcl_WinConvertError β€” manipulate errno to store and retrieve error codes. periodt. πŸ’…


🌈 SYNOPSIS 🌈

#include <tcl.h>

void
Tcl_SetErrno(errorCode)

int
Tcl_GetErrno()

const char *
Tcl_ErrnoId()

const char *
Tcl_ErrnoMsg(errorCode)

void
Tcl_WinConvertError(winErrorCode)

πŸŽ€ ARGUMENTS πŸŽ€

  • int errorCode (in) β€” a POSIX error code such as ENOENT. like, the vibe of the error, in integer form. πŸ“
  • DWORD winErrorCode (in) β€” a Windows or Winsock error code such as ERROR_FILE_NOT_FOUND. windows-flavoured chaos, delivered as a number. πŸͺŸ

πŸ’… DESCRIPTION πŸ’…

Tcl_SetErrno and Tcl_GetErrno are your portable little portals into the errno variable β€” the thing that records a POSIX error code after system calls and other operations such as Tcl_Gets. and why do these procedures need to exist at all, you ask? because global variable accesses cannot be made across module boundaries on some platforms. so instead of just reaching in and grabbing errno yourself, you go through these. iykyk. ✨

Tcl_SetErrno sets the errno variable to the value of the errorCode argument. so if you're writing C procedures that want to hand error info back to their callers via errno, you should be calling Tcl_SetErrno rather than setting errno directly. direct access? we don't know her. πŸ™ˆ

Tcl_GetErrno returns the current value of errno. procedures wishing to access errno should call this procedure instead of accessing errno directly. that's the whole bit. πŸ‘‘

Tcl_ErrnoId and Tcl_ErrnoMsg return string representations of errno values. Tcl_ErrnoId returns a machine-readable textual identifier such as EACCES that corresponds to the current value of errno. Tcl_ErrnoMsg returns a human-readable string such as β€œpermission denied” that corresponds to the value of its errorCode argument β€” and that errorCode argument is typically the value returned by Tcl_GetErrno. cute little pipeline, honestly. 🫢

🚨 IMPORTANT GIRL MATH: the strings returned by these functions are statically allocated, and the caller must not free or modify them. do not touch. do not edit. hands off the merch. 😭

Tcl_WinConvertError (Windows only) maps the passed Windows or Winsock error code to a POSIX error and stores it in errno. windows-to-posix translation service, slay. 🌈


πŸ”₯ KEYWORDS πŸ”₯

errno, error code, global variables. the whole aesthetic in three words. πŸ‘‘


and that's the page, bestie πŸ’œ this one came straight out of the Tcl manual, version 8.3, and it's filed under Tcl_SetErrno(3) β€” so if you ever need to find her again, she's right there. go forth and set your errno responsibly. mwah. πŸ’–βœ¨

πŸ“¦ where this page comes from