misleading warning message
massimiliano cialdi
massimiliano.cialdi@powersoft.it
Wed Jun 7 21:11:00 GMT 2017
gcc 6.3.0, compile this:
#include <stdio.h>
int main(void)
{
printf("%Ld\n",3L);
printf("%llf\n", 3.3L);
return 0;
}
this is the output:
$ gcc -pedantic -std=c99 -Wall test.c -o test
test.c: In function âmainâ:
test.c:5:12: warning: ISO C does not support the â%Ldâ gnu_printf format
[-Wformat=]
printf("%Ld\n",3L);
^
test.c:5:12: warning: format â%Ldâ expects argument of type âlong long
intâ, but argument 2 has type âlong intâ [-Wformat=]
test.c:6:13: warning: use of âllâ length modifier with âfâ type
character has either no effect or undefined behavior [-Wformat=]
printf("%llf\n", 3.3L);
^
the warning about '%Ld' is misleading. I was expecting something like
"use of âLâ length modifier with âdâ type character has either no effect
or undefined behavior", otherwise it looks that '%Ld' is allowed and
require âlong long intâ.
also printf(3) manpage says:
*"L:* A following *a*, *A*, *e*, *E*, *f*, *F*, *g*, or *G* conversion
corresponds to a /long double/ argument."
--
Powersoft logo <http://www.powersoft.it>
*Massimiliano Cialdi |*Senior Firmware Engineer
*skype:* mci.pws *| email:* massimiliano.cialdi@powersoft.it
<mailto:massimiliano.cialdi@powersoft.it>
*HQ Italy:* Via E. Conti, 5 *|* 50018 Scandicci (FI) Italy
*direct phone:* +39 055 0153429 *| Fax:* +39 055 735 6235
*web site:* www.powersoft.it <http://www.powersoft.it>
Green Audio Power
More information about the Gcc-help
mailing list