{"id":7428,"date":"2022-12-20T19:38:04","date_gmt":"2022-12-20T22:38:04","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/tcl_linkvar-man3-3\/"},"modified":"2022-12-20T19:38:04","modified_gmt":"2022-12-20T22:38:04","slug":"tcl_linkvar-man3-3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/tcl_linkvar-man3-3\/","title":{"rendered":"Tcl_LinkVar (man3)"},"content":{"rendered":"<h1 align=\"center\">Tcl_LinkVar<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#ARGUMENTS\">ARGUMENTS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_LinkVar, Tcl_UnlinkVar, Tcl_UpdateLinkedVar \u2212 link Tcl variable to C variable<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <tcl.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_LinkVar<\/b>(<i>interp, varName, addr, type<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_UnlinkVar<\/b>(<i>interp, varName<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_UpdateLinkedVar<\/b>(<i>interp, varName<\/i>)<\/p>\n<h2>ARGUMENTS <a name=\"ARGUMENTS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"37%\">\n<p style=\"margin-top: 1em\">Tcl_Interp <i>*interp<\/i> (in)<\/p>\n<\/td>\n<td width=\"15%\"><\/td>\n<td width=\"37%\">\n<p style=\"margin-top: 1em\">Interpreter that contains <i>varName<\/i>. Also used by <b>Tcl_LinkVar<\/b> to return error messages.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"37%\">\n<p>const char <i>*varName<\/i> (in)<\/p>\n<\/td>\n<td width=\"15%\"><\/td>\n<td width=\"37%\">\n<p>Name of global variable.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"37%\">\n<p>char <i>*addr<\/i> (in)<\/p>\n<\/td>\n<td width=\"15%\"><\/td>\n<td width=\"37%\">\n<p>Address of C variable that is to be linked to <i>varName<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"37%\">\n<p>int <i>type<\/i> (in)<\/p>\n<\/td>\n<td width=\"15%\"><\/td>\n<td width=\"37%\">\n<p>Type of C variable. Must be one of <b>TCL_LINK_INT<\/b>, <b>TCL_LINK_UINT<\/b>, <b>TCL_LINK_CHAR<\/b>, <b>TCL_LINK_UCHAR<\/b>, <b>TCL_LINK_SHORT<\/b>, <b>TCL_LINK_USHORT<\/b>, <b>TCL_LINK_LONG<\/b>, <b>TCL_LINK_ULONG<\/b>, <b>TCL_LINK_WIDE_INT<\/b>, <b>TCL_LINK_WIDE_UINT<\/b>, <b>TCL_LINK_FLOAT<\/b>, <b>TCL_LINK_DOUBLE<\/b>, <b>TCL_LINK_BOOLEAN<\/b>, or <b>TCL_LINK_STRING<\/b>, optionally OR\u2019ed with <b>TCL_LINK_READ_ONLY<\/b> to make Tcl variable read-only.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:63%;\">______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_LinkVar<\/b> uses variable traces to keep the Tcl variable named by <i>varName<\/i> in sync with the C variable at the address given by <i>addr<\/i>. Whenever the Tcl variable is read the value of the C variable will be returned, and whenever the Tcl variable is written the C variable will be updated to have the same value. <b>Tcl_LinkVar<\/b> normally returns <b>TCL_OK<\/b>; if an error occurs while setting up the link (e.g. because <i>varName<\/i> is the name of array) then <b>TCL_ERROR<\/b> is returned and the interpreter\u2019s result contains an error message.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>type<\/i> argument specifies the type of the C variable, and must have one of the following values, optionally OR\u2019ed with <b>TCL_LINK_READ_ONLY<\/b>: <b><br \/> TCL_LINK_INT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>int<\/b>. Any value written into the Tcl variable must have a proper integer form acceptable to <b>Tcl_GetIntFromObj<\/b>; attempts to write non-integer values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_UINT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>unsigned int<\/b>. Any value written into the Tcl variable must have a proper unsigned integer form acceptable to <b>Tcl_GetWideIntFromObj<\/b> and in the platform\u2019s defined range for the <b>unsigned int<\/b> type; attempts to write non-integer values (or values outside the range) into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_CHAR<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>char<\/b>. Any value written into the Tcl variable must have a proper integer form acceptable to <b>Tcl_GetIntFromObj<\/b> and be in the range of the <b>char<\/b> datatype; attempts to write non-integer or out-of-range values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_UCHAR<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>unsigned char<\/b>. Any value written into the Tcl variable must have a proper unsigned integer form acceptable to <b>Tcl_GetIntFromObj<\/b> and in the platform\u2019s defined range for the <b>unsigned char<\/b> type; attempts to write non-integer values (or values outside the range) into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_SHORT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>short<\/b>. Any value written into the Tcl variable must have a proper integer form acceptable to <b>Tcl_GetIntFromObj<\/b> and be in the range of the <b>short<\/b> datatype; attempts to write non-integer or out-of-range values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_USHORT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>unsigned short<\/b>. Any value written into the Tcl variable must have a proper unsigned integer form acceptable to <b>Tcl_GetIntFromObj<\/b> and in the platform\u2019s defined range for the <b>unsigned short<\/b> type; attempts to write non-integer values (or values outside the range) into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_LONG<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>long<\/b>. Any value written into the Tcl variable must have a proper integer form acceptable to <b>Tcl_GetLongFromObj<\/b>; attempts to write non-integer or out-of-range values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_ULONG<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>unsigned long<\/b>. Any value written into the Tcl variable must have a proper unsigned integer form acceptable to <b>Tcl_GetWideIntFromObj<\/b> and in the platform\u2019s defined range for the <b>unsigned long<\/b> type; attempts to write non-integer values (or values outside the range) into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_DOUBLE<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>double<\/b>. Any value written into the Tcl variable must have a proper real form acceptable to <b>Tcl_GetDoubleFromObj<\/b>; attempts to write non-real values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer or real representations (like the empty string, \u2019.\u2019, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_FLOAT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>float<\/b>. Any value written into the Tcl variable must have a proper real form acceptable to <b>Tcl_GetDoubleFromObj<\/b> and must be within the range acceptable for a <b>float<\/b>; attempts to write non-real values (or values outside the range) into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer or real representations (like the empty string, \u2019.\u2019, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_WIDE_INT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>Tcl_WideInt<\/b> (which is an integer type at least 64-bits wide on all platforms that can support it.) Any value written into the Tcl variable must have a proper integer form acceptable to <b>Tcl_GetWideIntFromObj<\/b>; attempts to write non-integer values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_WIDE_UINT<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>Tcl_WideUInt<\/b> (which is an unsigned integer type at least 64-bits wide on all platforms that can support it.) Any value written into the Tcl variable must have a proper unsigned integer form acceptable to <b>Tcl_GetWideIntFromObj<\/b> (it will be cast to unsigned); attempts to write non-integer values into <i>varName<\/i> will be rejected with Tcl errors. Incomplete integer representations (like the empty string, \u2019+\u2019, \u2019-\u2019 or the hex\/octal\/binary prefix) are accepted as if they are valid too.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_BOOLEAN<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>int<\/b>. If its value is zero then it will read from Tcl as \u201c0\u201d; otherwise it will read from Tcl as \u201c1\u201d. Whenever <i>varName<\/i> is modified, the C variable will be set to a 0 or 1 value. Any value written into the Tcl variable must have a proper boolean form acceptable to <b>Tcl_GetBooleanFromObj<\/b>; attempts to write non-boolean values into <i>varName<\/i> will be rejected with Tcl errors.<\/p>\n<p style=\"margin-left:11%;\"><b>TCL_LINK_STRING<\/b><\/p>\n<p style=\"margin-left:22%;\">The C variable is of type <b>char *<\/b>. If its value is not NULL then it must be a pointer to a string allocated with <b>Tcl_Alloc<\/b> or <b>ckalloc<\/b>. Whenever the Tcl variable is modified the current C string will be freed and new memory will be allocated to hold a copy of the variable\u2019s new value. If the C variable contains a NULL pointer then the Tcl variable will read as \u201cNULL\u201d.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the <b>TCL_LINK_READ_ONLY<\/b> flag is present in <i>type<\/i> then the variable will be read-only from Tcl, so that its value can only be changed by modifying the C variable. Attempts to write the variable from Tcl will be rejected with errors.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_UnlinkVar<\/b> removes the link previously set up for the variable given by <i>varName<\/i>. If there does not exist a link for <i>varName<\/i> then the procedure has no effect.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_UpdateLinkedVar<\/b> may be invoked after the C variable has changed to force the Tcl variable to be updated immediately. In many cases this procedure is not needed, since any attempt to read the Tcl variable will return the latest value of the C variable. However, if a trace has been set on the Tcl variable (such as a Tk widget that wishes to display the value of the variable), the trace will not trigger when the C variable has changed. <b>Tcl_UpdateLinkedVar<\/b> ensures that any traces on the Tcl variable are invoked.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that, as with any call to a Tcl interpreter, <b>Tcl_UpdateLinkedVar<\/b> must be called from the same thread that created the interpreter. The safest mechanism is to ensure that the C variable is only ever updated from the same thread that created the interpreter (possibly in response to an event posted with <b>Tcl_ThreadQueueEvent<\/b>), but when it is necessary to update the variable in a separate thread, it is advised that <b>Tcl_AsyncMark<\/b> be used to indicate to the thread hosting the interpreter that it is ready to run <b>Tcl_UpdateLinkedVar<\/b>.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_TraceVar(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">boolean, integer, link, read-only, real, string, trace, variable<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_LinkVar, Tcl_UnlinkVar, Tcl_UpdateLinkedVar \u2212 link Tcl variable to C variable <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3740],"class_list":["post-7428","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_linkvar"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7428"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7428\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}