delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/07/08:36:55

Date: Wed, 7 Jul 1999 15:34:13 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Edevaldo Pereira da Silva Junior <Edevaldo DOT Pereira AT motorola DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: TCL Port
In-Reply-To: <37823C63.64744AF9@motorola.com>
Message-ID: <Pine.SUN.3.91.990707153354.2851T-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 6 Jul 1999, Edevaldo Pereira da Silva Junior wrote:

> If I'm not wrong DJGPP declares it as unsigned but the TCL
> sources expect it to be a signed.

This is a bug in TCL.  ANSI C doesn't specify that time_t is signed.

> There are constants like "yesterday" that is a negative number.

You can always say "(time_t)-1" etc., this shouldn't break unless you
are seconds before year 2037...

> 	I'm not sure if this will break the TCL code, but some date comparison
> may have problems.

If something breaks as a result of time_t being unsigned, I suggest to
report it to the TCL maintainers as a bug.

> 	The problem is that DOMAIN and SIGN exists inside DJGPP but they are
> inside ./libm/math.h that replaces math.h if _DJGPP_USE_LIBM (or
> something similar) is declared.
> 	To solve this I would have to modify the test in the configure script
> to detect and use the correct libm and then patch the sources to define
> _DJGPP_USE_LIBM.

No, you need the symbol _USE_LIBM_MATH_H be defined *somewhere*.  This
can be either on one of the header files included by the sources, or
on the GCC command line.

> that have ifdefs for platform specific issues. It would be nice to keep
> all the changes inside this single file but it is not possible in this
> case because math.h is included before TCLPort.h.

Why can't you change the order of inclusion, and make TCLPort.h be
included before the system headers?  Granted, you need to talk to the
TCL maintainers, but given that they agree, it should work, I think.

> Is there any mean to
> define _DJGPP_USE_LIBM(or something similar ;)) in the makefile or the
> configure script? Globally?

An alternative would be to add -D_USE_LIBM_MATH_H to CFLAGS or
CPPFLAGS.

> 	The last one (for now) is something that I have been ignoring for years
> and I always wanted to ask about. It's about using %d with longs in
> printf. Does %d only work for 16 bits? What is right in this case? %ld?

Longs should be printed with %ld.  If the datum that is printed is
declared "long", then simply change %d to %ld and report this to the
maintainers as a bug.  If the datum is declared as a
platform-dependent type, like size_t or some such, the usual way to
solve these problems is to cast it to the widest possible integral
type supported by printf and use the corresponding format specifier.
For example, assuming some_type_t is never wider than a long:

	some_type_t foo;
	...
	printf ("%ld", (long)foo);

> Frequently is says that %d & %i are used for
> signed ints. But in our case signed ints are 32 bits, but the compiler
> generates a warning either way.

The compiler issues a warning because some platforms define int and
long differently.

> %D don't work as well.

Beware of %D: it's non-portable and its effect is highhly platform-
and compiler-dependent.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019