]> git.ipfire.org Git - thirdparty/squid.git/commit - compat/stdio.h
Portability: Provide stdio wrappers for 64-bit in cstdio C++ builds
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 6 Apr 2011 13:58:14 +0000 (01:58 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 6 Apr 2011 13:58:14 +0000 (01:58 +1200)
commit5b44c55d55ab67a19bb27ff7df00711a74a6e4e2
tree2770bc69d484087e6124bc87de615756f760ece7
parentb5a644fcdfcce5b105eb736e028542d273b65f1c
Portability: Provide stdio wrappers for 64-bit in cstdio C++ builds

stdio.h in that case on provides fgetpos64, fopen64 if
__USE_FILE_OFFSET64 is defined. It then checks whether a gcc-specific
 __REDIRECT macro is available (defined in sys/cdefs.h, depending on
__GNUC__ begin available).

If it is not available, it does a preprocessor #define.

Which <cstdio> undefines, with this comment:
 "// Get rid of those macros defined in <stdio.h> in lieu of real functions.".
When it does a namespace redirection ("namespace std { using ::fgetpos; }")
it goes blam, as fgetpos64 is available, while fgetpos is not.

To fix it, we need to supply global functions matching those
signatures (not macros).

e.g.

#include <stdio.h>
#if defined(__USE_FILE_OFFSET64) &&!defined(__REDIRECT) && defined(fgetpos)
#undef fgetpos
int fgetpos (FILE * f, fpos64_t *p) { return fgetpos64(f,p); }
#endif
#include <cstdio>

This every time we use <cstdio> (directly or indirectly).

This is triggered by us defining -D_FILE_OFFSET_BITS=64 when
--enable-large-files configure is used.
compat/GnuRegex.c
compat/Makefile.am
compat/assert.cc
compat/compat.h
compat/debug.h
compat/eui64_aton.c
compat/getnameinfo.c
compat/inet_ntop.c
compat/stdio.h [new file with mode: 0644]
compat/tempnam.c