how can I find the exact header file including a struct variable? eg. DIR?

Discussion in 'C Programming' started by hankssong, Dec 2, 2006.

  1. hankssong

    hankssong Guest

    hi all, I'm wondering how to locate the C header file where
    defines some struct variable,macro and function.
    In the MSDN, we can easily solve it by using INDEX search;
    but how we can do it in the Linux environment?
    I had tried man [1-8]DIR; but I found no result:)
    thanks in advance!
     
    hankssong, Dec 2, 2006
    #1
    1. Advertising

  2. hankssong

    santosh Guest

    hankssong wrote:
    > hi all, I'm wondering how to locate the C header file where
    > defines some struct variable,macro and function.
    > In the MSDN, we can easily solve it by using INDEX search;
    > but how we can do it in the Linux environment?
    > I had tried man [1-8]DIR; but I found no result:)
    > thanks in advance!


    Typically they're in /usr/include. Use cat <HEADER> | grep <PATTERN>.

    Ask further such questions in comp.os.linux etc.
     
    santosh, Dec 2, 2006
    #2
    1. Advertising

  3. hankssong

    MQ Guest

    santosh wrote:
    > hankssong wrote:
    > > hi all, I'm wondering how to locate the C header file where
    > > defines some struct variable,macro and function.
    > > In the MSDN, we can easily solve it by using INDEX search;
    > > but how we can do it in the Linux environment?
    > > I had tried man [1-8]DIR; but I found no result:)
    > > thanks in advance!

    >
    > Typically they're in /usr/include. Use cat <HEADER> | grep <PATTERN>.
    >
    > Ask further such questions in comp.os.linux etc.


    DIR is usually just a typedef for a struct. In <dirent.h> on my
    system:

    typedef struct __dirstream DIR

    If this is the case you may need to search further until you find it.
    Grep the files in the include directory (use -r to recurse subdirs)

    MQ.
     
    MQ, Dec 2, 2006
    #3
  4. hankssong said:

    > hi all, I'm wondering how to locate the C header file where
    > defines some struct variable,macro and function.


    What you're really asking is how to find a search pattern within a corpus of
    text files. This question is best asked within a group dealing with your
    system's command shell, or a regular expressions group.

    > In the MSDN, we can easily solve it by using INDEX search;
    > but how we can do it in the Linux environment?


    By thinking clearly and asking our question in the right place.

    Consider gnu.bash or comp.os.linux.development.apps as more plausible
    alternatives.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Dec 2, 2006
    #4
  5. MQ said:

    > DIR is usually just a typedef for a struct.


    No, usually DIR is a Win32 console command asking for a directory listing.
    There is a significant potential for confusion between the two terms when
    you have someone coming from a Windows background to a Linux environment,
    and comp.lang.c is not the best group to deal with such confusion.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Dec 2, 2006
    #5
  6. hankssong

    hankssong Guest

    thank you for all your help
    I had done some test and it seemss that the problem could be soloved ad
    follows:
    ctags -x -R /usr/lib/include > ref
    vim ref
    /\<DIR\> // find
    ctrl + ]
    ^_^
    "santosh дµÀ£º
    "
    > hankssong wrote:
    > > hi all, I'm wondering how to locate the C header file where
    > > defines some struct variable,macro and function.
    > > In the MSDN, we can easily solve it by using INDEX search;
    > > but how we can do it in the Linux environment?
    > > I had tried man [1-8]DIR; but I found no result:)
    > > thanks in advance!

    >
    > Typically they're in /usr/include. Use cat <HEADER> | grep <PATTERN>.
    >
    > Ask further such questions in comp.os.linux etc.
     
    hankssong, Dec 2, 2006
    #6
  7. hankssong

    CBFalconer Guest

    Re: how can I find the exact header file including a struct variable?eg. DIR?

    santosh wrote:
    > hankssong wrote:
    >
    >> hi all, I'm wondering how to locate the C header file where
    >> defines some struct variable,macro and function.
    >> In the MSDN, we can easily solve it by using INDEX search;
    >> but how we can do it in the Linux environment?
    >> I had tried man [1-8]DIR; but I found no result:)
    >> thanks in advance!

    >
    > Typically they're in /usr/include. Use cat <HEADER> | grep <PATTERN>.
    >
    > Ask further such questions in comp.os.linux etc.


    He can try "cat n869.txt | grep <PATTERN>" also. A suitable
    bzipped version of N869 (the draft C99 standard) can be found at:

    <http://cbfalconer.home.att.net/download/>

    Another useful sequence is:

    less -p<PATTERN> <n869.txt

    In all cases replace <PATTERN> with the string of interest.

    These sequences apply to systems with the appropriate Unix flavored
    utilities only. They can be made available on most systems. On
    others the n869.txt is still applicable, but how to search it is up
    to you.

    I simply capture the whole sequence in an alias named 'cstd', so I
    don't have to worry about what sort of system I am running.

    --
    Chuck F (cbfalconer at maineline dot net)
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net>
     
    CBFalconer, Dec 2, 2006
    #7
  8. hankssong

    MQ Guest

    Richard Heathfield wrote:

    > No, usually DIR is a Win32 console command asking for a directory listing.
    > There is a significant potential for confusion between the two terms when
    > you have someone coming from a Windows background to a Linux environment,
    > and comp.lang.c is not the best group to deal with such confusion.


    I would doubt there is any confusion, as the title suggests a struct
    variable named DIR, not a Win32 console command

    MQ
     
    MQ, Dec 3, 2006
    #8
  9. MQ said:

    >
    > Richard Heathfield wrote:
    >
    >> No, usually DIR is a Win32 console command asking for a directory
    >> listing. There is a significant potential for confusion between the two
    >> terms when you have someone coming from a Windows background to a Linux
    >> environment, and comp.lang.c is not the best group to deal with such
    >> confusion.

    >
    > I would doubt there is any confusion, as the title suggests a struct
    > variable named DIR, not a Win32 console command


    If you read it in one way, yes. Sort of "how can I find the header
    containing DIR". I do see that. But what you may have missed is that it is
    also possible to read it another way (along the lines of "what am I
    supposed to use to find <stuff in files>? DIR?"). And the text of the
    original article suggests an operating system search technique: "we can
    easily solve it by using INDEX search", which seems to me (although of
    course I could be wrong) to be a reference to Microsoft's facility to
    search within files - a sort of poor man's grep.

    So yes, the possibility for confusion does exist, and I think he needs to
    sort it out elsenet on this occasion.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Dec 3, 2006
    #9
  10. hankssong

    MQ Guest

    Richard Heathfield wrote:

    "we can
    > easily solve it by using INDEX search", which seems to me (although of
    > course I could be wrong) to be a reference to Microsoft's facility to
    > search within files - a sort of poor man's grep.


    IIRC from my Windows programming days, you can highlight a
    type/variable in a source file and tell Vis ual C to search for its
    definition.

    MQ
     
    MQ, Dec 3, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    18
    Views:
    7,196
    Karl Heinz Buchegger
    Jul 22, 2005
  2. dw
    Replies:
    7
    Views:
    1,364
  3. Hans Müller
    Replies:
    1
    Views:
    571
    Emile van Sebille
    Mar 19, 2010
  4. Kga Agk
    Replies:
    2
    Views:
    168
    Kga Agk
    Jun 29, 2009
  5. Replies:
    8
    Views:
    230
    Thomas 'PointedEars' Lahn
    Mar 8, 2006
Loading...

Share This Page