eg:
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <linux/msm_ion.h>
#include <utils/Log.h>
#include "QSEEComAPI.h"
#include "common_log.h"
#include <sys/mman.h>
#include <semaphore.h>
注意:在linux中,大部分的頭文件都在/usr/include目錄下, 如果頭文件前再有目錄,比如sys/stat.h, 則在/usr/include下會有相應sys目錄,然后cd進去,再查看頭文件即可.
還可以通過find /usr/include -name stat.h 或try "/usr/include/sys/sat.h"去搜索。
如果不知道該函數的用法,可以通過man函數,man 2 stat去試一下(其中2代表man手冊的第二節),該函數的用法和所需要的頭文件;
示例:
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
int main() {
struct stat buf;
stat("/etc/hosts", &buf);
printf("/etc/hosts file size = %d\n", buf.st_size);