Where to find the complete definition of off_t type?

后端 未结 4 695
猫巷女王i
猫巷女王i 2020-11-30 20:40

I am sending file from client to server using TCP. To mark the end of the file I like to send file size before the actual data. So I use stat system call to fin

4条回答
  •  悲&欢浪女
    2020-11-30 21:16

    If you are having trouble tracing the definitions, you can use the preprocessed output of the compiler which will tell you all you need to know. E.g.

    $ cat test.c
    #include 
    $ cc -E test.c | grep off_t
    typedef long int __off_t;
    typedef __off64_t __loff_t;
      __off_t __pos;
      __off_t _old_offset;
    typedef __off_t off_t;
    extern int fseeko (FILE *__stream, __off_t __off, int __whence);
    extern __off_t ftello (FILE *__stream) ;
    

    If you look at the complete output you can even see the exact header file location and line number where it was defined:

    # 132 "/usr/include/bits/types.h" 2 3 4
    
    
    typedef unsigned long int __dev_t;
    typedef unsigned int __uid_t;
    typedef unsigned int __gid_t;
    typedef unsigned long int __ino_t;
    typedef unsigned long int __ino64_t;
    typedef unsigned int __mode_t;
    typedef unsigned long int __nlink_t;
    typedef long int __off_t;
    typedef long int __off64_t;
    

    ...

    # 91 "/usr/include/stdio.h" 3 4
    typedef __off_t off_t;
    

提交回复
热议问题