Re: __atoi64 not working correctly
From: Chris Croughton (chris_at_keristor.net)
Date: 01/22/05
- Next message: Till Crueger: "Re: convert a list to tree"
- Previous message: Sontu: "Re: To find the size of array using its pointer"
- In reply to: Jack Klein: "Re: __atoi64 not working correctly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 22 Jan 2005 08:42:23 +0000
On Fri, 21 Jan 2005 23:09:27 -0600, Jack Klein
<jackklein@spamcop.net> wrote:
> <off-topic>
>
> mingw is a "typical" gcc distribution, as is available for many
> platforms. It provides a tools like compiler and linker, and headers,
> but no library. It uses the platform's standard run-time library, in
> this case Microsoft's MSVC something or other DLL.
Aha! I knew there must be something different...
> The *printf() implementation in Microsoft's C library merely ignores
> the first 'l' in an "%lld" or other "%ll" conversion specifier, and
> treats the argument as a long, not a 32-bit value.
Why am I not surprised?
> So if you want real long long support under Windows, you need an
> implementation that provides its own library and supports it. These
> include lcc-win32, Pelles C, and probably the gcc implementation that
> runs under Cygwin, but I don't know this last one for sure.
I can say for sure (and did in an earlier message) -- it works fine. It
still isn't 100% compliant, though, as I recall it doesn't support %a or
the v (maxint) length modifier for integers. And some of the new macros
are missing from header files.
> </off-topic>
As someone else said recently, this means that in practice what real C
programmers have to work to is the C89/90 standard, we can be pretty
sure in most cases that compilers will support that (there are a few
unfortunate programmers who still have to support things without
function prototypes). The C99 standard is largely irrelevant from the
point of view of writing portable code, and will be until the majority
of the C compilers available are C99 compliant (modulo bugs, of course).
For instance, I want to determine the 'best' floating point type for my
application (enough significant digits with the least storage to do
that) in the
preprocessor. Simple, right? Something like
#include <float.h>
#if FLT_MANT_DIG >= 10
typedef float my_float;
#if DBL_MANT_DIG >= 10
typedef double my_float;
#if LDBL_MANT_DIG >= 10
typedef long double my_float;
#else
# error No useful floating type!
#endif
Wrong! It's fine for C99, where the values are required to be constant
integer expressions, but C89 says:
Of the values in the <float.h> header, FLT_RADIX shall be a constant
expression suitable for use in #if preprocessing directives; all
other values need not be constant expressions. All except FLT_RADIX
and FLT_ROUNDS have separate names for all three floating-point
types. The floating-point model representation is provided for all
values except FLT_ROUNDS .
(para 2.2.4.1). So the only way to test them is to have a program which
includes float.h and then prints out a header file containing
appropriate definitions (for that and other reasons I have such a
program which calculates a load of stuff about the environment -- like
the number of bits in integer types -- and outputs a header file with
the information because things like sizeof aren't allowed in
preprocessor tests).
Chris C
- Next message: Till Crueger: "Re: convert a list to tree"
- Previous message: Sontu: "Re: To find the size of array using its pointer"
- In reply to: Jack Klein: "Re: __atoi64 not working correctly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|