Skip to content

Commit d5f8109

Browse files
cyanogilvieclaude
andcommitted
Fix Windows cross-compilation
- Add -DBUILD_rl_json so stubs API functions get DLLEXPORT - Use %zu/%s for size_t format strings (Tcl_ObjPrintf lacks %zu on 8.6) - Use Tcl_WideInt for pointer-sized values in debug leak-info command Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d2539b4 commit d5f8109

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

generic/parser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ void throw_parse_error(Tcl_Interp* interp, struct parse_error* details) //{{{
2020
{
2121
char char_ofs_buf[20]; // 20 bytes allows for 19 bytes of decimal max 64 bit size_t, plus null terminator
2222

23-
snprintf(char_ofs_buf, 20, "%ld", details->char_ofs);
23+
snprintf(char_ofs_buf, 20, "%zu", details->char_ofs);
2424

25-
Tcl_SetObjResult(interp, Tcl_ObjPrintf("Error parsing JSON value: %s at offset %ld", details->errmsg, details->char_ofs));
25+
Tcl_SetObjResult(interp, Tcl_ObjPrintf("Error parsing JSON value: %s at offset %s", details->errmsg, char_ofs_buf));
2626
Tcl_SetErrorCode(interp, "RL", "JSON", "PARSE", details->errmsg, details->doc, char_ofs_buf, NULL);
2727
}
2828

generic/rl_json.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3739,14 +3739,14 @@ static int jsonNRObj(ClientData cdata, Tcl_Interp* interp, int objc, Tcl_Obj *co
37393739
case M_LEAK_OBJ: Tcl_NewObj(); break;
37403740
case M_LEAK_INFO:
37413741
{
3742-
unsigned long addr;
3742+
Tcl_WideInt addr;
37433743
Tcl_Obj* obj = NULL;
37443744
const char* s;
37453745
Tcl_Size len;
37463746

37473747
CHECK_ARGS(2, "addr");
3748-
TEST_OK(Tcl_GetLongFromObj(interp, objv[2], (long*)&addr));
3749-
obj = (Tcl_Obj*)addr;
3748+
TEST_OK(Tcl_GetWideIntFromObj(interp, objv[2], &addr));
3749+
obj = (Tcl_Obj*)(intptr_t)addr;
37503750
s = Tcl_GetStringFromObj(obj, &len);
37513751
fprintf(stderr, "\tLeaked obj: %p[%" TCL_SIZE_MODIFIER "d] len %" TCL_SIZE_MODIFIER "d: \"%s\"\n", (void*)obj, obj->refCount, len, len < 256 ? s : "<too long>");
37523752

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ endif
1313

1414
add_project_arguments('-Wno-missing-field-initializers', language: 'c')
1515
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
16+
add_project_arguments('-DBUILD_rl_json', language: 'c')
1617

1718
pkg_sources = []
1819
conf = configuration_data() # For C code (config.h)

0 commit comments

Comments
 (0)