Guangmu Zhu
Guangmu Zhu

Reputation: 31

Why do I get implicit declaration of function 'open64'/'openat'/'openat64' warning on Ubuntu?

gcc 4.8.2

#define __USE_FILE_OFFSET64
#define __USE_LARGEFILE64
#include <fcntl.h>

int
main(void) {
    int fd = open64("/", O_RDONLY);
    return 0;
}

Then gcc's output is 'warning: implicit declaration of function ‘open64’ [-Wimplicit-function-declaration]'. But in fcntl.h:

#ifndef __USE_FILE_OFFSET64
extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
#else
# ifdef __REDIRECT
extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
     __nonnull ((1));
# else
#  define open open64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1));
#endif

Function openat/openat64 has the same problem even though #define __USE_ATFILE is added. I have no idea what happened to these.

Upvotes: 2

Views: 1451

Answers (1)

keltar
keltar

Reputation: 18399

Correct define flag for LARGEFILE64 is _LARGEFILE64_SOURCE. All your __USE_* manipulations are undone by features.h.

Upvotes: 5

Related Questions