2015年12月30日 星期三

健身資料參考

http://firen7254.pixnet.net/blog/post/41845744
http://www.mr-sport.com.tw/post/four-shoulder-weight-training.html
http://flyandwings.q168.net/

2015年12月28日 星期一

Implementation of sizeof operator

#define my_sizeof(x) ((&x + 1) - &x)
#define my_sizeof(x) ((char *)(&x + 1) - (char *)&x)

編譯多個source code

如何編譯多個source code,以下以GNU C compiler gcc作說明:

假設有以下檔案:ispvm_ui.c hardware.c ivm_core.c vmopcode.h

# gcc -c ispvm_ui.c hardware.c ivm_core.c 
會產生兩個object file
# gcc -o ispvm_ui ispvm_ui.o hardware.o ivm_core.o
連結三個object file產生ispvm_ui的執行檔

如果後來ispvm_ui.c做了更改,我們只須重新編譯ispvm_ui.c即可
# gcc -o ispvm_ui ispvm_ui.c hardware.o ivm_core.o

2015年12月13日 星期日

[Linux] 搜尋資料夾底下 檔案內部文字

find "path name" -name "file name" -exec grep -H "search content" {} \;

find原本是用「檔案名稱」來搜尋在哪些地方有這些檔案,將這些路徑結果餵給grep後,就可以拿來搜尋檔案內部的文字片段。

Ex:
find ./kernel -name "*.c" -exec grep -H "main" {} \;
以上這段指令,是要搜尋./kernel底下所有的.c檔,內容含有"main"的地方。

find的參數:
  -name 要搜尋哪些檔名
  -exec utility name [argument...{} \;
    搜尋出的檔名 交給哪個執行檔(utility name)處理
    {} 會被find搜尋後的檔名路徑名稱所取代
    \; 代表exec的參數到此為止

grep的參數:
  -H 列出搜尋到的檔案名稱路徑