[問題] 動態連結程式庫實作
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
gcc, Linux
問題(Question):
在念 程式設計師的自我修養 一書中看到的 在第185頁
簡單說有兩支程式 他們都呼叫一個寫在Lib.h/Lib.c的函式foobar
(程式碼在下方)
然後下指令: gcc -fPIC -shared -o Lib.so Lib.c 來產生.so檔案
問題是:為什麼這邊的Lib.c不用include Lib.h???
程式碼(Code):(請善用置底文網頁, 記得排版)
// Lib.c
#include <stdio.h>
void foobar( int i )
{
// Do something;
}
// Lib.cpp
#ifndef LIB_H
#define LIB_H
void foobar( int i );
#endif
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.225.10.108
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1434723346.A.BB7.html
※ 編輯: peter98 (36.225.10.108), 06/19/2015 22:18:05
→
06/19 22:21, , 1F
06/19 22:21, 1F
→
06/19 23:28, , 2F
06/19 23:28, 2F
→
06/19 23:28, , 3F
06/19 23:28, 3F
→
06/20 10:57, , 4F
06/20 10:57, 4F