作者apologize (人生在世很愜意)
看板C_and_CPP
標題[問題] 我想要A.c 檔裏面包含 B.c 檔的函式
時間Thu Dec 10 13:49:18 2015
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
C
問題(Question):
A.c 檔案包含 B.c 檔的函式要怎樣寫?
錯誤結果(Wrong Output):
aram undefined -> compile error
程式碼(Code):(請善用置底文網頁, 記得排版)
A.c
--
#include "b.h"
int main (void) {
aram();
return;
}
--
b.h
--
#ifndef _B_H_
#define _B_H_
void aram (void);
#endif
--
b.c
--
void aram (void) {
prinf ("test");
return;
}
--
--
補充說明(Supplement):
程式碼另外打的,可能有漏請指正。目前對照結果跟我寫的差不多。
大概是這種感覺,就是寫了之後就compiler error 就說a 檔案沒有被定義aram這函式。
那請問要怎樣寫?
--
志願役普遍垃圾不代表每個志願役都是垃圾。
苗栗人智商普遍低落,不代表每個苗栗人智商都很低。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.30.118
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1449726562.A.384.html
→ Caesar08: 隨便猜的,因為沒有把b.c加入編譯? 12/10 14:16
→ apologize: 請問怎麼加? 12/10 14:30
→ Caesar08: gcc a.c b.c 12/10 14:34
→ apologize: 謝謝了,成功了 12/10 14:35