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.

3 Answers 3

3

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
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:

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
1
  • This is a great answer as it can be easily modified to use any other keywords for other languages.
    – not2qubit
    Dec 2, 2019 at 14:28

You must log in to answer this question.