[splint-discuss] splint doesn't like unsigned long long?

Richard O'Keefe ok at cs.otago.ac.nz
Sun Nov 14 17:17:54 PST 2010


On 14/11/2010, at 3:31 AM, Greg White wrote:
> 
> What is the C89 equivalent?

There is no C89 equivalent of %lld.
There is no C89 way to get integers that are *guaranteed* to be
64 bits, although there is nothing in C89 that says longs can't
be that size, and indeed in some compilation modules with some
compilers they *will* be.  Here is a transcript.

m% cat foo.c
#include <stdio.h>

int main(void) {
    printf("%d\n", (int)sizeof (long int));
    return 0;
}

m% gcc -m64 foo.c
m% a.out
8

Indeed, C89 orthodoxy was that this was the way that you *ought* to
get at 64-bit integers, but they got overtaken by gcc practice, and
decided to make the de facto standard the de jure one.
>  
> Unsigned long isn't large enough and I don't need any decimal places.  Can float handle large numbers without decimal places?

IEEE 'double' arithmetic gives you *exact* integer addition, subtraction,
comparison, and multiplication for numbers up to ±2^53 or thereabouts.
Division and remainder are trickier, but you can program them using fmod().

> If there is no long long C89 equivalent then How do I test for C99 compliance?

I wish I had the time to put some work into splint instead of just using it.
gcc -ansi -pedantic -std=c99
isn't _perfect_, but it's a lot better than nothing.




More information about the splint-discuss mailing list