This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

FW: using _FILE_OFFSET_BITS=64 with a non-gcc compiler

[Get raw message]
> Martin v. Loewis wrote on 13/11/01 4:13 PM:
> Neither, nor. However, that is precisely the reason why a system
> header most not introduce a #define for readdir64. Looking at C99,
> 4p6, we see
> # A conforming implementation may have extensions (including
> # additional library functions), provided they do not alter the
> # behavior of any strictly conforming program.
> with a footnote saying
> # This implies that a conforming implementation reserves no
> # identifiers other than those explicitly reserved in this
> # International Standard.

It gets even better.

C (and POSIX) say that (with carefully noted exceptions) the application
is assured of an actual function, not just a macro, and can get a pointer
to the function after doing a #undef.
This allows for an application to use arrays of ptrs-to-func.

[ISO C 99 Sec 7.1.4 Use of library functions]

There are other, equally crufty, but conforming ways of doing this.
Here is one:

/* and that's how I'll get it */
static struct dirent *readdir(DIR *__dirarg)
extern struct dirent64 *readdir64(DIR *);
return (proper casting here, I'm too lazy) readdir64(DIR *__dirarg);
#else /* _XOPEN_SOURCE */
extern size_t wcsftime(wchar_t *, size_t, const char *, const struct tm *);
#endif /* _XOPEN_SOURCE */

extern  struct dirent *readdir(DIR *);

Mark S. Brown                                   

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]