Development/Sal Types

    From The Document Foundation Wiki

    Sal_* types have been created to be helpers. They need to be strictly preserved when dealing with ABI and/or data-serialization. Some code mix Sal_* types with other types.

    • Because they map to different integral types on different platforms, using them with printf style functions (such as OSL_TRACE) is cumbersome.
    Fortunately there is a SAL_DEBUG macro that uses stream overloads so you don't need to worry about the types when debugging:
    SAL_DEBUG("GetLayoutOffset " << nLayout);
    • Here are some examples of how to correctly use them with printf style functions if you really have to (but it's much easier to use SAL_DEBUG instead):

    1) i is defined as sal_uInt32 so:

    Prefer

    DBG(printf( "call ImplCreateSlide( %"SAL_PRIuUINT32" )\n", i));

    over

    DBG(printf( "call ImplCreateSlide( %d )\n", i));

    2) nLayout is defined as sal_Int32 so :

    Prefer

    DBG(printf("GetLayoutOffset %"SAL_PRIdINT32"\n", nLayout));

    over

    DBG(printf("GetLayoutOffset %d\n", nLayout));

    3) intValue is defined as sal_Int32 and you want hex value :

    Prefer

    printf ("%"SAL_PRIdINT32" (hex: %"SAL_PRIxUINT32")\n", intValue, intValue);

    over

    printf ("%d (hex: %x)\n", intValue, intValue);