[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] parameter declarations and long doubles

From: Dave Dodge
Subject: Re: [Tinycc-devel] parameter declarations and long doubles
Date: Thu, 8 Jun 2006 17:53:58 -0400
User-agent: Mutt/1.4.2i

On Thu, Jun 08, 2006 at 08:36:11AM -0700, Jim Cook wrote:
> Is there an online reference for, et al.? I don't have a dead-tree
> version handy and would be more than happy to research such things myself
> before posting questions.

As someone mentioned, N1124 is the best online one.  N869 is also
available and comes in a plaintext version that may be easier to
browse in a text editor, but a downside to N869 is that it's a pre-C99
draft and doesn't exactly match the final standard.  N1124 is based on
the final C99 document so it should be more accurate.

If you need the official (non-draft) versions for some reason, you can
purchase them from ANSI or ISO.

> Do you have an online reference for the right printf arguments?

In N1124 it's in section  It states that "L" is used for
printing a long double, and that "l" has no effect on "f".

> >Also, keep in mind that the actual implementation of "printf" is
> >provided by the system's C library, not tcc.
> This answer gave me pause for a while until I realized you meant that when
> the TCC binary was compiled, it was _that_ compiler that is responsible.

More likely I just don't know enough about how tcc is packaged for
Windows.  In the Unix world the C compiler and the C library are
separated.  The compiler doesn't normally provide header files or code
for functions such as fprintf and malloc; it assumes you have a C
library package installed that will supply them.

On Linux the library package is usually glibc or uClibc.  On a
commercial Unix system it would be provided by the vendor (Sun, Apple,
HP, etc).  The Unix C library has to implement a lot of very
system-specific things, such as the arguments for the ioctl()
function, and it's traditionally been easier to let the vendor deal
with that stuff.

> Windows binary distribution
> <http://laurenssimonis.com/tcc/tcc-0.9.23.zip>maintained by Laurens
> Simonis.

Okay, it looks like he's taken tcc and bundled it with some other
things to make it usable on Windows.  The header files for example
come from the MinGW package.

> It appears that using either %lf or %Lf has the same result when passed a
> long double.

I think what's happening is that tcc (and MinGW) link your program
with "msvcrt.dll", which is Microsoft's Visual C++ C runtime library.
You end up with Microsoft's implementation of printf.  A problem
you're going to run into is that Microsoft's C library does not
conform to the C standard:


Here's what Microsoft had to say about C99 conformance back in 2003:

  "In general, we have seen little demand for many C99 features. Some
  features have more demand than others, and we will consider them in
  future releases provided they are compatible with C++. It is more
  likely we'll entertain C99 features if they are picked up in the
  next version of the C++ standard."

> I also happen to know that in the compilers from them, long double
> and double are not different, so perhaps that's part of the
> strangeness.

Right, tcc is linking your code against the same version of printf
that those compilers use.  According to the MinGW documentation, that
printf doesn't actually support long doubles at all:


                                                  -Dave Dodge

reply via email to

[Prev in Thread] Current Thread [Next in Thread]