原來會有這個現象還跟不同平台的行尾有關
Linux 行尾: \n (0x0A) -> LF(LineFeed)
Windows 行尾: \r\n (0x0D, 0x0A) -> CR LF (CarriageReturn LineFeed)
之前我在 .gitconfig 檔案內
新增了
原來會有這個現象還跟不同平台的行尾有關
Linux 行尾: \n (0x0A) -> LF(LineFeed)
Windows 行尾: \r\n (0x0D, 0x0A) -> CR LF (CarriageReturn LineFeed)
之前我在 .gitconfig 檔案內
新增了
usb drive 來回 windows/linux 過程中, 有時會出現不當的操作導致 linux 環境下 usb drive 變成 read-only
在 linux 這邊要下指令 remount
sudo mount -o remount,rw /xxx/usb-drivecpp 的 compiler 會把 funcion 再添加一些東西,
當 cpp 直接 invoke c function, compile 很容易產生 symbol 錯亂問題.
解法
1. c header file 加上 defensive guard
常見的 FIFO reader 範例是
open("fifo", O_RDONLY | O_NONBLOCK);一旦搭配 select, 會發現 select 經常被 trigger,
失去了 select 該有的功效 ...
原來當 peer 關掉 write end of FIFO,
使用 gettid 獲取 thread id, compile 卻發生 error -> error: ‘gettid’ was not declared in this scope
照定義, 應該只要 include <sys/types.h> 即可,
但事與願違 ...
最後才找到有人分享 workaround
新增兩個 shell script 方便多檔案的 git status 和 git add
複習以前學過的, 也學習以前不知道的 shell script 檔案處理工具用法.
1. status.sh
if [ $# == 2 ]
then
PARSER=$1
TARGET=$2
直接傳一個固定大小的 buffer 可能會因為 size 不夠而產生 Host not resolved 錯誤,
所以要看回傳值, 動態配置大小.
Reference:
http://stackoverflow.com/questions/6517478/how-to-use-gethostbyname-r-in-linux