apropos
とman
apropos [text]
manファイルを検索できます。例:
$ apropos malloc
__malloc_hook (3) - malloc debugging variables
malloc (3) - Allocate and free dynamic memory
malloc_hook (3) - malloc debugging variables
mtrace (1) - Interpret output from MALLOC_TRACE
mtrace (3) - malloc debugging
muntrace (3) - malloc debugging
XtMalloc (3) - memory management functions
次に、manページを見ることができます。
$ man malloc
NAME
calloc, malloc, free, realloc - Allocate and free dynamic memory
SYNOPSIS
#include <stdlib.h>
void *calloc(size_t nmemb, size_t size);
void *malloc(size_t size);
void free(void *ptr);
void *realloc(void *ptr, size_t size);
DESCRIPTION
calloc() allocates memory for an array of nmemb elements of size bytes
each and returns a pointer to the allocated memory. The memory is set
#include <stdlib.h>
それが欠けていることを明らかにします。
find
とgrep
apropos
次の例のように機能しない場合は、を使用find
しgrep
てすべてのソースファイルを検索できます。
//#include "stdint.h"
#include <stdio.h>
main() {
int8_t *xy = (int8_t*) 1;
printf("%p\n", xy);
}
test.c: In function ‘main’:
test.c:4: error: ‘int8_t’ undeclared (first use in this function)
test.c:4: error: (Each undeclared identifier is reported only once
test.c:4: error: for each function it appears in.)
test.c:4: error: ‘xy’ undeclared (first use in this function)
test.c:4: error: expected expression before ‘)’ token
ソリューション:
moose@pc07:/usr/include$ find *.h | xargs grep "int8_t"
db.h: u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
db.h: u_int8_t *bp; /* Allocated read buffer. */
db.h: u_int8_t /* Unique file ID. */
db.h: int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
db.h: int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
db.h: int (*prepare) __P((DB_TXN *, u_int8_t *));
db.h: u_int8_t gid[DB_GID_SIZE];
db.h: u_int8_t gid[DB_GID_SIZE]; /* Global transaction ID */
db.h: u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
db.h: (pointer = (u_int8_t *)(dbt)->data + \
db.h: retdata = (u_int8_t *)(dbt)->data + *__p--; \
db.h: if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \
db.h: retkey = (u_int8_t *)(dbt)->data + *__p--; \
db.h: retdata = (u_int8_t *)(dbt)->data + *__p--; \
db.h: retdata = (u_int8_t *)(dbt)->data + *__p--; \
db.h: pointer = (u_int8_t *)(dbt)->data + \
db.h: u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
db.h: if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \
db.h: (u_int8_t *)(__p - 2)) \
db.h: writedata = (u_int8_t *)(dbt)->data + __off; \
db.h: u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
db.h: if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \
db.h: (writedlen) > (u_int8_t *)(__p - 4)) { \
db.h: writekey = (u_int8_t *)(dbt)->data + __off; \
db.h: writedata = (u_int8_t *)(dbt)->data + __off; \
db.h: pointer = (u_int8_t *)(dbt)->data + \
db.h: u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
db.h: if (((u_int8_t *)(dbt)->data + __off) + (writedlen) > \
db.h: (u_int8_t *)(__p - 3)) \
db.h: writedata = (u_int8_t *)(dbt)->data + __off; \
db.h: u_int8_t *lk_conflicts; /* Two dimensional conflict matrix */
db.h: int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *));
db.h: int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
stdint.h:#ifndef __int8_t_defined
stdint.h:# define __int8_t_defined
stdint.h:typedef signed char int8_t;
stdint.h:typedef unsigned char uint8_t;
xf86drmMode.h:extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
xf86drmMode.h: uint8_t bpp, uint32_t pitch, uint32_t bo_handle,