Linux编程常见问题
錯(cuò)誤提示:Makefile:2: *** 遺漏分隔符 。 停止。
原因makefile中 gcc語句前 缺少一個(gè) tab分割符
錯(cuò)誤提示: bash: ./makefile: 權(quán)限不夠
原因 makefile 是文本文件不可執(zhí)行,即使是root,也會(huì)權(quán)限不夠
我們應(yīng)該在命令行下使用make, 該指令會(huì)自動(dòng)搜尋所在目錄下的makefile文件,如果使用其他名稱如(makefile.am)則應(yīng)加參數(shù)指出,如:make -f makefile.am
錯(cuò)誤提示 : a.c:6: 錯(cuò)誤:程序中有游離的 ‘\200’
a.c:6: 錯(cuò)誤:程序中有游離的 ‘\200’
a.c:8: 錯(cuò)誤:程序中有游離的 ‘\343’
a.c:8: 錯(cuò)誤:程序中有游離的 ‘\200’
a.c:8: 錯(cuò)誤:程序中有游離的 ‘\200’
原因
這個(gè)錯(cuò)誤一般是由于你程序(a.c)中使用了中文的標(biāo)點(diǎn)符號,比如;,},+。
改成英文的就行了。
甚至有時(shí)候空格也會(huì)出現(xiàn)類似錯(cuò)誤,刪掉該空格 重新輸入。
如果找不出來,解決的辦法就是關(guān)閉中文輸入法然后把有錯(cuò)這一行重新敲一遍。
錯(cuò)誤 提示 :
0警告:隱式聲明與內(nèi)建函數(shù) ‘printf’ 不兼容
1 警告: 隱式聲明與內(nèi)建函數(shù) ‘malloc’ 不兼容??
2警告: 隱式聲明與內(nèi)建函數(shù) ‘exit’ 不兼容???
3警告:隱式聲明與內(nèi)建函數(shù) ‘execlp’ 不兼容
4警告:隱式聲明與內(nèi)建函數(shù) ‘strlen’ 不兼容
5 錯(cuò)誤:‘FILE’ 未聲明?? (//使用 fopen)
解決方法:
加上頭文件
0#include "stdio.h"
1#include <malloc.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <string.h>
5#include <stdio.h>
C類型字符串 后面有一個(gè) '\0 ' 作為 結(jié)尾標(biāo)示符隱含加入。
sizeof(a) 就包括了 '\0 '
而strlen(a) 沒有將 '\0 '計(jì)算在內(nèi)。
錯(cuò)誤:‘O_RDONLY’ 未聲明
來源 fd = open("test.file", O_RDONLY);
解決:
?? ?? #include <fcntl.h>
?? ??? int open(const char *pathname, int oflag, ... /* mode_t mode */);
??? ??? 語法參考:http://baike.baidu.com/view/26337.htm
區(qū)別于:
??? #include<stdio.h>
??? FILE * fopen(const char * path,const char * mode);
????? 語法參考:http://baike.baidu.com/view/656681.htm
錯(cuò)誤:‘CLONE_VM’ 未聲明
錯(cuò)誤:‘CLONE_FILES’ 未聲明
來源: 使用clone時(shí)候?? clone(do_something, child_stack, CLONE_VM|CLONE_FILES, NULL);
解決: #include <sched.h>
錯(cuò)誤:‘pid_t’ 未聲明
來源: /*定義子進(jìn)程號 */ ?? pid_t pid;
解決:
??? ??? ??? #include <stdlib.h>
錯(cuò)誤:‘options’ 的存儲大小未知
來源 : union semun options;???????????? http://dev.yesky.com/199/7643199_1.shtml
原因: semun定義問題
??? ??? /usr/include/linux/ipc.h 中有定義
??? ??? 但是 /usr/include/sys/ipc.h 中沒有
??? 而通常程序會(huì)包含 sys/ipc.h sys/sem.h 不可能去包含 linux/ipc.h, linux/sem.h, 否則不可能在unix 下通過
解決:
union semun {
?? ?? ?? ?? ?? int val;
?? ?? ?? ?? ?? struct semid_ds *buf;
?? ?? ?? ?? ?? ushort *array;
}arg;
總結(jié)
以上是生活随笔為你收集整理的Linux编程常见问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何调试你的C#程序
- 下一篇: C语言中的CONST使用