Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

manコマンドでC標準関数を調べる

コマンドの意味を知る時に使う、manコマンド。
実は...同名のC言語ライブラリ関数を調べる事ができます。
例えば、printf(3)とかです。

何もやらなければ

$ man printf | head -n 6

PRINTF(1)                 BSD General Commands Manual                PRINTF(1)

NAME
     printf -- formatted output

とでてきますが、セクション番号を指定することでC言語ライブラリのリファレンスを呼び出したりできます

[ ~ ]$ man 3 printf | head -n 10

PRINTF(3)                BSD Library Functions Manual                PRINTF(3)

NAME
     printf, fprintf, sprintf, snprintf, asprintf, dprintf, vprintf, vfprintf,
     vsprintf, vsnprintf, vasprintf, vdprintf -- formatted output conversion

LIBRARY
     Standard C Library (libc, -lc)

以前扱ったstrtokもこの通り。

$ man 3 strtok | head -n 8

STRTOK(3)                BSD Library Functions Manual                STRTOK(3)

NAME
     strtok, strtok_r -- string tokens

LIBRARY
     Standard C Library (libc, -lc)

ライブラリ自体を調べる事も。

$ man 3 string | head -n 20

STRING(3)                BSD Library Functions Manual                STRING(3)

NAME
     index, rindex, stpcpy, strcasecmp, strcat, strchr, strcmp, strcpy,
     strcspn, strerror, strlen, strncasecmp, strncat, strncmp, strncpy,
     strpbrk, strrchr, strsep, strspn, strstr, strtok -- string specific func-
     tions

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <strings.h>

     char *
     index(const char *s, int c);

     char *
     rindex(const char *s, int c);

stdioとてこの通り。

$ man 3 stdio | head -n 8

STDIO(3)                 BSD Library Functions Manual                 STDIO(3)

NAME
     stdio -- standard input/output library functions

LIBRARY
     Standard C Library (libc, -lc)

必ずしもCだけって訳でもないようで、
探すとperlのもあったりします

$ man 3 lib | head -n 8
lib(3pm)               Perl Programmers Reference Guide               lib(3pm)



NAME
       lib - manipulate @INC at compile time

SYNOPSIS