Skip to content
Tcl Source Code View Ticket
Login

View Ticket

format string warnings on FreeBSD 4-STABLE with gcc 2.95.4

Closed / Fixed1548330fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-08-29 05:46:48
These warnings appear to be legitimate.  According to
the ANSI C standard, the "%ld" format specifier
literally means "long int".  The arguments (members of
the ByteCode structure) being passed were declared as
"int".

/home/tcl/tcl8.5/tcl/unix/../generic/tclCompile.c: In
function `TclPrintByteCodeObj':
/home/tcl/tcl8.5/tcl/unix/../generic/tclCompile.c:2940:
warning: long int format, int arg (arg 4)
/home/tcl/tcl8.5/tcl/unix/../generic/tclCompile.c:2940:
warning: long int format, int arg (arg 6)
/home/tcl/tcl8.5/tcl/unix/../generic/tclCompile.c:2940:
warning: long int format, int arg (arg 7)
/home/tcl/tcl8.5/tcl/unix/../generic/tclCompile.c:2940:
warning: long int format, int arg (arg 8)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c: In
function `PrintByteCodeInfo':
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6306:
warning: long int format, int arg (arg 4)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6306:
warning: long int format, int arg (arg 6)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6306:
warning: long int format, int arg (arg 7)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6306:
warning: long int format, int arg (arg 8)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c: In
function `EvalStatsCmd':
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6856:
warning: long int format, int arg (arg 3)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6856:
warning: long int format, int arg (arg 4)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6877:
warning: long int format, int arg (arg 3)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6877:
warning: long int format, int arg (arg 4)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6877:
warning: long int format, int arg (arg 5)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6877:
warning: long int format, int arg (arg 6)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6971:
warning: long int format, int arg (arg 3)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6971:
warning: long int format, int arg (arg 4)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6971:
warning: long int format, int arg (arg 5)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6971:
warning: long int format, int arg (arg 6)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6984:
warning: long int format, int arg (arg 3)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6984:
warning: long int format, int arg (arg 4)
/home/tcl/tcl8.5/tcl/unix/../generic/tclExecute.c:6984:
warning: long int format, int arg (arg 5)
dasplain2006-08-29 13:29:12
Logged In: YES 
user_id=90580

what a pain...

gcc4 on Darwin gives the opposite warning about needing %ld rather than %d, 
because the ints you mention are multiplied by a sizeof, which causes 
promotion to an unsigned long (as sizeof returns a size_t).
Maybe size_t is an int on your platform, or gcc2 is buggy about this?

Now added casts to (unsigned long) to make both compilers happy
Log in (anonymous is fine) to add a comment.