Archive for April, 2009

ternary operator blues

Wednesday, April 15th, 2009

ISO/IEC 9899:TC3 Committee Draft — Septermber 7, 2007 WG14/N1256

6.5.15 Conditional operator

If both the second and third operands have arithmetic type, the result type that would be determined by the usual arithmetic conversions, were they applied to those two operands, is the type of the result.

i.e.

#include <stdio.h>

void SetLong (long foo)
{
    fprintf(stderr, "Got a long of %ld\n", foo);
}

int main(void)
{
    int a = -10;
    unsigned int b = 10;

    /*int converted to long*/
    SetLong( a );
    /*unsigned int converted to long*/
    SetLong( b );
    /* int and unsigned int results converted to unsigned int,
       unsigned int then converted to long. i.e. totally different
       from if (1) SetLong(a); else SetLong(b); */
    SetLong( 1 ? a : b );

    return 0;
}

On 32bit Linux long and int are the same size, so it doesn’t matter and we get -10, 10, -10, on 64bit they’re not and so results in -10, 10 and 4294967286

DEV300_m46

Monday, April 13th, 2009

DEV300_m46 callcatcher results, +32 to 1181 unused methods. (as against that, binfilter and chart2 have pending workspaces to strip them of a pile of methods)

casual code annotation

Friday, April 10th, 2009

I want a sort of casual code annotation wiki-thing where I can annotate code in passing without having to check it in to a formal source repository,