以#include 為例,分析Linux系統下編譯所需要頭文件


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);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM