how to get structure elements?

K

k3rb

hi everyone sorry for the stupid question but I can't figure it out how
I can get elements of a structure?
example I want to get all the elements in the structure which I don't
know?
I am trying to find out where are inode_t, FILE and DIR structures but
I can find them?
thanks for your help in advanced
 
B

Bharath

Didn't get your question! Are you asking about the data types inode_t?
Have you checked in the relevant header (.h) files?
 
M

Martin Ambuhl

k3rb said:
hi everyone sorry for the stupid question but I can't figure it out how
I can get elements of a structure?
example I want to get all the elements in the structure which I don't
know?
I am trying to find out where are inode_t, FILE and DIR structures but
I can find them?
thanks for your help in advanced
inode_t and DIR structures are not standard C. The pointer to FILE is,
but the type is intended to be opaque. There is nothing in a FILE
struct that can be assumed to be portable; it is completely
implementation-specific. If you want to play the dangerous game of
looking inside those black boxes, you may want to look to
system-specific headers. On the implementation I use most often, the
struct FILE is defined in <stdio.h>, but this is not guaranteed. On the
other hand, the non-standard struct DIR is *not* defined in the
non-standard header <dirent.h>; what is there is a typedef to a library
internal struct. The source for that internal struct is available, but
that need not be true. If you *really* need this kind of information --
think carefully before saying 'yes' -- ask in a newsgroup for your
implementation.
 
S

SM Ryan

# hi everyone sorry for the stupid question but I can't figure it out how
# I can get elements of a structure?

You can't do it within the language: C doesn't support that kind of introspection.

# example I want to get all the elements in the structure which I don't
# know?
# I am trying to find out where are inode_t, FILE and DIR structures but
# I can find them?
# thanks for your help in advanced

Depends on the implementation and operating system.
You might be able to do something like

echo '#include <stdio.h>' > /tmp/x.c
cc -E /tmp/x.c >x.i
grep -B 100 '} FILE' x.i
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,901
Members
47,439
Latest member
elif2sghost

Latest Threads

Top