# derick@php.net / 2005-03-27 07:49:31 +0200:
> On Sun, 27 Mar 2005, Roman Neuhauser wrote:
> > I'm having a puzzling problem with %lld conversion handling
> > in ap_php_snprintf, and it seems to be gcc version-dependent.
> >
> > I found this problem through Statgrab, which has this macro:
> >
> > #define PHP_SG_ADD_LLVAL(rtz, key, val) { \
> > char tmp[256]; \
> > int tmp_len = snprintf((char *)&tmp, sizeof(tmp) - 1, "%lld", val); \
> > add_assoc_stringl_ex(rtz, key, sizeof(key), tmp, tmp_len, 1); \
> > }
> >
> > main/snprintf.[hc]:
> >
> > #define snprintf ap_php_snprintf
> > PHPAPI int ap_php_snprintf(char *buf, size_t len, const char *format,...)
>
> For some reason the header file is not included then
That doesn't seem to be the case. The library is built with
cc -I. -I/usr/ports/sysutils/pecl-statgrab/work/Statgrab-0.3 -DPHP_ATOM_INC -I/usr/ports/sysutils/pecl-statgrab/work/Statgrab-0.3/include -I/usr/ports/sysutils/pecl-statgrab/work/Statgrab-0.3/main -I/usr/ports/sysutils/pecl-statgrab/work/Statgrab-0.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -I/usr/local/include -DHAVE_CONFIG_H -O -pipe -prefer-pic -c /usr/ports/sysutils/pecl-statgrab/work/Statgrab-0.3/statgrab.c -o statgrab.o >/dev/null 2>&1
and when I replace "-o statgrab.o >/dev/null 2>&1" with "-E" I see:
# 65 "/usr/local/include/php/main/snprintf.h"
int ap_php_snprintf(char *, size_t, const char *, ...) __attribute__ ((format(printf, 3, 4)));
and the macro calls expanded to use ap_php_snprintf().
Plus, this program works on the machines where the Statgrab extension
produces "%ld":
#include <stdio.h>
int
main (int argc, char **argv)
{
char tmp[256];
int tmp_len = snprintf((char *)&tmp, sizeof(tmp) - 1, "%lld", 127LL);
printf("strlen (%s) == %d\n", tmp, tmp_len);
return 0;
}
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991