From: SourceForge.net <no...@so...> - 2004-04-30 19:55:47
|
Bugs item #926486, was opened at 2004-03-31 02:09 Message generated for change (Comment added) made by tauvan You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=926486&group_id=10894 Category: None Group: development: 8.5a2 Status: Open Resolution: Remind Priority: 5 Submitted By: Don Porter (dgp) Assigned to: Joe English (jenglish) Summary: remove stdio.h from tcl.h ? Initial Comment: Lines 141-143 of tcl.h: #ifndef BUFSIZ # include <stdio.h> #endif I have to assume that getting BUFSIZ defined is not the point, as that never gets used within tcl.h. Within all of Tcl's C code BUFSIZ only shows up in unix/tclLoadAix.c and that file unconditionally #include-s stdio.h for itself. So, I take it that the #ifndef BUFSIZ test is just in place to prevent a double #include of stdio.h, perhaps on some strange system somewhere with a botched stdio.h that's not safe to #include more than once? Anyhow, the main point seems to be to get at the declarations of stdio.h. But why? Nothing else in tcl.h has need of those declarations. Several things throughout Tcl need stdio.h, but they get it already, either by a #include of tclInt.h -- which #include's stdio.h unconditionally -- or by just #include-ing stdio.h for themselves. Is it for the benefit of packages that #include "tcl.h" ? That seems bizarre. If a package needs stdio.h, it's logical for it to #include it for itself. If not, then Tcl is forcing it into the picture where it's not needed. Seems these 3 lines could just be removed with no loss, and arguable gain. ---------------------------------------------------------------------- Comment By: tauvan (tauvan) Date: 2004-04-30 14:55 Message: Logged In: YES user_id=1011552 Sorry, more specifically, it is #define'd in <sys/unistd.h>, but the same #ifndef... as in tclUnixPort.h, is in <stdio.h>. ---------------------------------------------------------------------- Comment By: tauvan (tauvan) Date: 2004-04-30 13:25 Message: Logged In: YES user_id=1011552 Yes, there is mine is in unistd.h! ---------------------------------------------------------------------- Comment By: tauvan (tauvan) Date: 2004-04-30 13:15 Message: Logged In: YES user_id=1011552 Here's a strange question. In tclUnixPort.h it includes tclInt.h which includes stdio.h. In tclUnixPort.h the following: #ifndef SEEK_SET # define SEEK_SET 0 #endif #ifndef SEEK_CUR # define SEEK_CUR 1 #endif #ifndef SEEK_END # define SEEK_END 2 #endif Was or is there a time when SEEK_SET, SEEK_CUR, SEEK_END not defined or differently defined? ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2004-04-30 08:32 Message: Logged In: YES user_id=80530 OK, I found a reason not to do this. Not a good reason, mind you, but a reason. A program that wants to call Tcl_Seek() or Tcl_FSSeek() will #include <tcl.h> to get their declarations. In order to call them, though, it's best to pass them the values SEEK_SET, SEEK_CUR, or SEEK_END. Those values are #define'd in <stdio.h>. Probably would be better if Tcl defined its own values for passing to its own routines, but as things are, it appears tcl.h ought to include stdio.h after all. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2004-04-25 15:11 Message: Logged In: YES user_id=80530 fixed in HEAD. ---------------------------------------------------------------------- Comment By: Joe English (jenglish) Date: 2004-04-25 09:37 Message: Logged In: YES user_id=68433 Existing extension code that assumes <tcl.h> includes <stdio.h> can easily be updated to include <stdio.h> themselves. We don't guarantee 100% source-level compatibility across minor revision numbers. ---------------------------------------------------------------------- Comment By: tauvan (tauvan) Date: 2004-04-04 23:26 Message: Logged In: YES user_id=1011552 Suggestion: It looks like that stdio was not a compatiblity issue and was needed by most files, so delete the three lines, add #include <stdio.h> at the very top of "tcl.h". Almost every file includes "tclInit.h" which includes "tcl.h" and 13 files reference it plus it's the first thing in "tclInit.h". ---------------------------------------------------------------------- Comment By: Joe English (jenglish) Date: 2004-03-31 09:51 Message: Logged In: YES user_id=68433 Agree 100% with dgp's assessment: this can go. It looks like it hasn't been needed since Tcl 7.6 when the channel system was added. (Prior to that there were public routines that took FILE *s.) As for extensions that need stdio.h but don't bother including it because they've already included tcl.h: they can fix themselves. Tcl has never guaranteed absolute source-level compatibility for extensions at minor releases. This is an easy fix for extension authors, and adding #include <stdio.h> won't introduce a retro-incompatibility with pre-8.5 headers. It can go. ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2004-03-31 03:53 Message: Logged In: YES user_id=79902 I think we can probably remove the BUFSIZ test from there, but I worry that much existing extension code assumes that stdio.h was implied by tcl.h, so perhaps the #include can't go until 9.0? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=926486&group_id=10894 |