Is it possible to view structure definitions using man pages the way we can see function definitions in UNIX?
For instance, for network programming, we use a structure called struct sockaddr_in
. Is there anyway to see how sockaddr_in has been defined in the library using man pages?
Any help will be appreciated! Thanks!
For any given header:
echo '#include <netinet/in.h>' | gcc -E - | less
Which generates of relevant interest:
# 225 "/usr/include/netinet/in.h" 3 4
struct sockaddr_in
{
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
unsigned char sin_zero[sizeof (struct sockaddr) -
(sizeof (unsigned short int)) -
sizeof (in_port_t) -
sizeof (struct in_addr)];
};
This can be done using any compiler with a preprocessor option (every C compiler I know of can do this).
It depends on the function. For example, you can get the definition of struct sockaddr
by looking at the man page of bind(2)
.
Unfortunately, there's no man page specifically for struct sockaddr
.
Other ways to get this information would be to search for it the appropriate header files.
man-pages is just a files written by human or generated by wish of human. Usually all related structures is mentioned in man-pages with functions they used with. Sometimes you can find pages for header-files ( time.h(0p) ). Sometimes there is pages for a whole libraries ( libsensors(3) ). Sometimes there is actual pages for structures ( XAnyEvent(3) ).
You may want to check apropos
and whatis
. Sometimes they able to find pages related with what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With