Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Pointer size warnings when compiling on a 32-bit machine

Closed / Fixed36bcf04a704a22f3578ea0d93e0401eb5d0afcb3Created 3 years agoUpdated 3 years ago
Descriptionplain2023-08-09 11:18:23
Edited to shorten paths:

generic/tclInt.h:4358:12: warning: incompatible pointer types passing 'Tcl_Size *' (aka 'long *') to parameter of type 'int *' [-Wincompatible-pointer-types]
    return TclGetIntFromObj(interp, objPtr, sizePtr);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
generic/tclInt.h:2757:46: note: expanded from macro 'TclGetIntFromObj'
            : Tcl_GetIntFromObj((interp), (objPtr), (intPtr)))
                                                    ^~~~~~~~
generic/tclDecls.h:152:27: note: passing argument to parameter 'intPtr' here
                                Tcl_Obj *objPtr, int *intPtr);
chrstphrchvzwiki2023-08-10 11:45:06

The warning is about how C considers pointers to different integer types to be incompatible, regardless of whether the types have the same size.

TCL_SIZE_MAX == INT_MAX does not necessarily mean Tcl_Size is int. Using a temporary int avoids the warning; see attached patch.

chrstphrchvzwiki2023-08-28 06:39:37

The patch I attached was superseded by [2e65fce4cf]. But should Tcl be assuming that TCL_SIZE_MAX == INT_MAX implies sizeof(Tcl_Size) == sizeof(int)? Since the condition is no longer meant for the preprocessor, should Tcl just check sizeof(…) instead?

jan.nijtmanswiki2023-08-28 08:06:13

> should Tcl just check sizeof(…) instead?

It doesn't really matter (IMHO), but since TCL_SIZE_MAX is non-C-standard it would be - slightly - better.

Closing. [e94242449556e1fd]

Log in (anonymous is fine) to add a comment.

Attachments: