系统调用

以Ubuntu系统中的readdir函数为例。

一:     #include <dirent.h>

    (dp = opendir(argv[1])) = NULL

    (dirp = readdir(dp)) != NULL

二:

    在 /usr/include中, dirent.h。

    #include <bits/dirent.h>

    #ifndef __USE_FILE_OFFSET64
      extern struct dirent *readdir (DIR *__dirp) __nonnull ((1));
   #else
   # ifdef __REDIRECT
         extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64)
         __nonnull ((1));
   # else
   #  define readdir readdir64
   # endif
   #endif

三:

    在/usr/include/x86_64-linux-gun/bits中 , dirent.h.

    #ifndef _DIRENT_H
   # error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
   #endif

   struct dirent
   {
    #ifndef __USE_FILE_OFFSET64
      __ino_t d_ino;
      __off_t d_off;
    #else
      __ino64_t d_ino;
      __off64_t d_off;
    #endif
      unsigned short int d_reclen;
      unsigned char d_type;
      char d_name[256];       /* We must not include limits.h! */

    };  

原文地址:https://www.cnblogs.com/gavinwu/p/3391721.html