Tcl_SetErrno(3tcl)
π Tcl_SetErrno β bestie edition π
okay so this is a page from the Tcl Library Procedures manual, and it's literally about Tcl_SetErrno, Tcl_GetErrno, Tcl_ErrnoId, Tcl_ErrnoMsg, and Tcl_WinConvertError β the whole squad that manipulates errno so you can store and retrieve error codes. no cap. π«Ά
β¨ NAME β¨
Tcl_SetErrno, Tcl_GetErrno, Tcl_ErrnoId, Tcl_ErrnoMsg, Tcl_WinConvertError β manipulate errno to store and retrieve error codes π
πΈ 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, likeENOENT. yes bestie, that kind of thing πDWORD winErrorCode(in) β a Windows or Winsock error code, likeERROR_FILE_NOT_FOUND. very Windows-coded of it πͺ
π DESCRIPTION π
so Tcl_SetErrno and Tcl_GetErrno are your portable hookup to the errno variable β that's the thing that records a POSIX error code after system calls and other operations, such as Tcl_Gets. and why do these procedures even need to exist, you ask? because global variable accesses literally cannot be made across module boundaries on some platforms. it's giving necessary, fr fr. π
Tcl_SetErrno sets the errno variable to the value of the errorCode argument. so if you're writing C procedures that wanna hand error info back to their callers via errno, call Tcl_SetErrno instead of setting errno directly. do not go rogue. π
Tcl_GetErrno returns the current value of errno. any procedure wishing to access errno should call this procedure instead of accessing errno directly. same energy, but the correct way π«Ά
Tcl_ErrnoId and Tcl_ErrnoMsg return string representations of errno values:
Tcl_ErrnoIdreturns a machine-readable textual identifier, such as"EACCES", that corresponds to the current value oferrno. π€Tcl_ErrnoMsgreturns 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 byTcl_GetErrno. cute lil pipeline, honestly β¨
β οΈ okay important: the strings returned by these functions are statically allocated, so the caller must not free or modify them. not even a little. don't touch. it's giving hands off π₯
Tcl_WinConvertError (Windows only, bestie) maps the passed Windows or Winsock error code to a POSIX error and stores it in errno. very translator era of it π
π KEYWORDS π
errno, error code, global variables
and that's the whole page!! this one's from the Tcl 8.3 era, dated back in the Tcl_SetErrno(3tcl) era of the world, sitting in the Tcl Library Procedures manual π thanks for reading bestie, go forth and never set errno directly again πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms