I am using ssize_t
in a piece of C code. I don't know which header file it is declared. So I start googling and then get buried and lost among many unrelated stuff.
This scenario happens over and over again to me, and it wastes much time. So, is there a conventional, probably efficient solution where you professional C coders find the right header file, or maybe you just remember them in mind? Thanks.
Types don't require a corresponding C file, so that's a bit difficult.
If you know a function that uses the type, you can often read it's manual page, and see which headers are needed. For example you might know that ssize_t
is returned by read(2)
, and then the friendly manual page: says:
#include <unistd.h> ssize_t read(int fd, void *buf, size_t count);
So clearly including <unistd.h>
must provide a definition of ssize_t
in addition to the function.
Another approach is grep:ing the system include directories, that's brute force but often helpful.