[haiku-development] Re: %Ld in Haiku code

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 27 Oct 2010 20:00:25 +0200

On 2010-10-27 at 19:05:47 [+0200], François Revol <revol@xxxxxxx> wrote:
> Le 27 oct. 2010 à 18:58, Grzegorz Dąbrowski a écrit :
> > I wonder what does %Ld mean? It's widely used in Haiku code and
> > according to standards [1] and clang [2] it is incorrect.
> > 
> > [1] http://www.opengroup.org/onlinepubs/009695399/
> > [2] warning: length modifier 'L' results in undefined behavior or no
> > effect with 'd' conversion specifier [-Wformat]
> 
> It's a GCCism for %lld (is this one standardized ?).

According to POSIX [1]:

"ll (ell-ell)

    Specifies that a following d , i , o , u , x , or X conversion specifier 
applies to a long long or unsigned long long argument; or that a following n 
conversion specifier applies to a pointer to a long long argument.|

"L
    Specifies that a following a , A , e , E , f , F , g , or G conversion 
specifier applies to a long double argument."

> When possible those should be fixed to conform to the standard, either %lld 
> if that's it, or those PRI* macros when appropriate.
> 
> Note however, that in some places (bootloader mostly) the set of format 
> qualifiers is smaller than the standard, and I recall having issues with 
> %lld at least once, maybe in BSD code ?

The boot loader and kernel *printf() support "L" and "ll" for both integer 
and float types.

CU, Ingo

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/fprintf.html

Other related posts: