Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-06-05
03:16 • Closed ticket [926486ffff]: remove stdio.h from tcl.h ? plus 8 other changes artifact: 317795acdf user: dgp
2004-05-01
02:55 • Ticket [926486ffff]: 4 changes artifact: b06fb5f68b user: tauvan
01:25 • Ticket [926486ffff]: 4 changes artifact: ebcf7351ee user: tauvan
01:15 • Ticket [926486ffff]: 4 changes artifact: e278d521db user: tauvan
2004-04-30
20:32 • Open ticket [926486ffff]. artifact: 58c3b8f294 user: dgp
2004-04-26
03:11 • Closed ticket [926486ffff]. artifact: 3777447893 user: dgp
2004-04-25
21:37 • Ticket [926486ffff]: 4 changes artifact: 9e4ac36a11 user: jenglish
2004-04-05
11:26 • Ticket [926486ffff]: 4 changes artifact: 8ce69e1221 user: tauvan
2004-03-31
21:51 • Ticket [926486ffff]: 4 changes artifact: 533243bc32 user: jenglish
15:53 • Ticket [926486ffff]: 4 changes artifact: abfc0b2bf8 user: dkf
07:09 • New ticket [926486ffff]. artifact: 6e6941cb18 user: dgp

remove stdio.h from tcl.h ?

Closed / Rejected926486ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 22 years ago
Descriptionplain2004-03-31 07:09:12
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.
dkfplain2004-03-31 15:53:33
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?
jenglishplain2004-03-31 21:51:10
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.
tauvanplain2004-04-05 11:26:59
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".
jenglishplain2004-04-25 21:37:54
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.
dgpplain2004-04-26 03:11:59
Logged In: YES 
user_id=80530

fixed in HEAD.
dgpplain2004-04-30 20:32:20
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.
tauvanplain2004-05-01 01:15:26
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?
tauvanplain2004-05-01 01:25:32
Logged In: YES 
user_id=1011552

 Yes, there is mine is in unistd.h!
tauvanplain2004-05-01 02:55:46
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>.
dgpplain2004-06-05 03:16:44
Logged In: YES 
user_id=80530


stdio.h restored to tcl.h for the
sake of the SEEK_* #define's
and for the sake of many
extensions that have come to
depend on it being there.
Log in (anonymous is fine) to add a comment.