Skip to content
Tcl Source Code View Ticket
Login

View Ticket

macOS 13 SDK deprecates sprintf()

Closed / Fixed0cb3554903fc141964afbaaee2602e1fe9906e88Created 4 years agoUpdated 57 days ago
Descriptionwiki2023-03-26 10:29:37
sprintf() is deprecated as of the macOS 13 SDK, causing many compiler warnings to be emitted when building Tcl, e.g.:
tcl/generic/regerror.c:77:2: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
        sprintf(convbuf, "%d", r->code); /* -1 for unknown */
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.")
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^

I notice sprintf() has recently been eradicated from Tk 8.6; will there be a similar effort for Tcl 8.6, or is this won’t-fix for 8.6?

Referenced by4
jan.nijtmanswiki2023-03-28 14:19:53

I think it would be wise to do the same for Tcl 8.6 (and up) too.

jan.nijtmanswiki2023-09-12 12:49:19

Fixed [here]

Closing

chrstphrchvzwiki2026-10-06 23:25:38

Reopening: after this ticket was closed, the tip-688 branch was merged, introducing two calls to sprintf().

tcl91/generic/tclClockFmt.c:3461:26: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
 3461 |                     dateFmt->output += sprintf(dateFmt->output, map->tostr, val);
      |                                        ^
tcl91/generic/tclClockFmt.c:3493:22: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]
 3493 |                 dateFmt->output += sprintf(dateFmt->output, map->tostr, val);
      |                                    ^

chrstphrchvz Open ticket [0cb3554903]. [History diff]2026-10-06 23:26:00
jan.nijtmanswiki2026-10-07 11:07:35

Fixed (again) [here] and in core-9-0-branch too.

Thanks for the reminder!

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