2

I'm a newbie in Linux programming. I found that the way to view the list of system calls in Linux via command-line is:

man syscalls

But now I want to view the list of c library functions, how can I do that? Which command will help me list the c library functions? And another question, where are system calls and c library functions manual pages located? Thank you.

2

There is an offline documentation browser that I have found helpful, called Zeal, that is similar to Dash.

Other options:

whereis glibc

or

dpkg -L *libc*

And open the files in a text editor.

To recursively search inside files for string:

grep -R "some string" /path/to/includes

Some paths to consider:

  • /usr/local/include
  • /usr/target/include
  • /usr/include

Other options may include:

| improve this answer | |
2

There is a nice package to display C function header, named ref. To know more about it see man ref. It has a good database where you can find the list of C library functions.

The functions are listed in the file /usr/share/elvis/stubs/ansistub.c. You can directly look into it to see the functions, or you can filter them as you wish.

You can use the following big line in your terminal to see the full list at once,

cat /usr/share/elvis/stubs/ansistub.c | grep "^int\|^char\|^void\|^double\|^ldiv_t\|^unsigned\|^type\|^struct\|^FILE\|^size_t\|^time_t\|^long\|^clock\|^mbstowcs\|^div_t" | awk 'NR > 12' | less

You will get Output like

void abort(void)
int abs(int num)
double acos(double cosvalue)
char *asctime(const struct tm *currtime)
double asin(double sinvalue)
void assert(int expression)
int atexit(void(*func)(void))
long int atol(const char *string)

....

Or you can copy the list to a file myCfunction.list using,

cat /usr/share/elvis/stubs/ansistub.c | grep "^int\|^char\|^void\|^double\|^ldiv_t\|^unsigned\|^type\|^struct\|^FILE\|^size_t\|^time_t\|^long\|^clock\|^mbstowcs\|^div_t" | awk 'NR > 12' > myCfunction.list

To use it first install ref using the command below,

sudo apt-get install elvis-tools
| improve this answer | |
  • This is a great answer as it can be easily modified to use any other keywords for other languages. – not2qubit Dec 2 '19 at 14:28
2

Which command will help me list the c library functions?

Here is one way to list all functions defined in the standard C library (GNU libc):

nm -D /lib/$(uname -m)-linux-gnu/libc-*.so | grep -vw U | grep -v "_" | cut -d " " -f3

Note that the system calls will also be included as they are actually functions that wrap the real system calls.

Where are system calls and c library functions manual pages located?

System call manual pages are under:

/usr/share/man/man2

Library functions manual pages are under:

/usr/share/man/man3
| improve this answer | |
-1

Just write

man 3

And press tab 2 times.

| improve this answer | |
  • 2
    This invokes shell-completion with a lot of results - impossible to find a specific category. – guntbert Sep 28 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy