2010年6月19日 星期六
cygwin之home directory
今天因為發現自己的Home directory目錄變了,於是很直覺的修改/etc/passwd,發現還是不行,後來在http://www.cygwin.com/faq/faq.setup.html的#16發現到,原來如果local端的cygwin如果有設定HOME,就會以HOME的目錄當成home directory,所以,我在/etc/passwd怎麼修改都沒用。
洛克菲勒的初識
在張忠謀董事長讚許郭台銘總裁為台灣的洛克斐勒之後,就對"洛克斐勒"這個人非常的好奇,於是在網路上找到了他的一些資料,平凡的出身卻能創造非凡的成就,而且在功成名就之後極力的行善更是令人讚賞,個人對於他自己對自己的一生下的總結有一些感受:
I was early taught to work as well as play, My life has been one long, happy holiday; Full of work and full of play- I dropped the worry on the way- And God was good to me everyday.生活是一種美學,把人生當成是一個假期,全心的工作,全力的體驗人生,一步一步的往自己的目標前進,自然就會達到"勇者無懼,仁者無敵,智者無惑"的境界,說白了,煩惱也沒用,對事情不會有所改變,猜想未來,對未來也不會有所幫助,謹慎的思考方向,勇敢的前進,努力的達成目標,人生自然就會關關難過關關過,而且,人生不是只有單調的"成功",而是多元的成功,事業的成功,家庭的成功,健康的成功,生活的成功等等,我想洛克斐勒都達到了,這是讓我極為崇拜的人物。
2010年6月6日 星期日
(轉貼)巧妙移除PDF文件的浮水印
PDF電子文件為了標示文章的來源出處,有時候會在頁面加入浮水印,但是浮水印若是插在文中很容易造成閱讀上的不便,你可以利用Adobe Acrobat 6的「TouchUp」文字工具,來移除PDF上文字的浮水印。
STEP:
1.在Adobe Acrobat中開啟要移除浮水印的PDF檔,然後在功能表按下【工具】→【進階編輯工具】→【TouchUp文字工具】。
2.接著在浮水印文字上按住滑鼠左鍵拖曳選取,然後按一下滑鼠右鍵,在快速選單選擇【內容】。
3.開啟「TouchUp內容」對話盒後,按下「填充」色塊,然後在色盤上選擇「無色彩」,再按下〔關閉〕按鈕。
4.回到Acrobat視窗後,可以看到每個頁面中的浮水印全部都消失了哦,這時候就可以將它另存新檔囉!
http://blog.xuite.net/wcwu1/vicky/9523182
標籤:
tools - text
GCC (4.4.1)之C Preprocessor part II
這一篇主要是CPP manual第三章macro的心得,所以都是在講述macro。
object-like macro是最簡單的macro,就是直接將macro的name取代成code。 如:
#define NUMBER 1, \
2, \
3,
int x[] = {NUMBER}
-> int x[] = { 1, 2 3 };
NUMBER會被展開誠1, 2, 3當macro被展開之後,會再度的被檢驗是否還有macro需要被展開。 如:
#define TABLESIZE BUFSIZE #define BUFSIZE 1024 TABLESIZE -> BUFSIZE -> 1024TABLESIZE會先被展開成BUFSIZE,接著BUFSIZE再被展成1024。
Function-like macro用起來就像在用function,所以被稱為function-like macro。function-like macro是在macro name後面"緊"接括號。 如:
#define lang_init() c_init() lang_init() -> c_init()
當macro name後面緊接著(),這個macro才會被當成function-like macro,否則會當成一般macro展開。 如:
extern void foo(void); #define foo() boo() .... foo(); // macro funcptr = foo; // function #define lang_init () c_init() // 多了空白在name和()之間 lang_init() -> () c_init()() // 結果就會造成錯誤
macro arguments,function macro可以像一般function一帶參數,這些參數會先被展開,接著再展開macro,參數要以","區隔開來(和一般的function一樣)。 如:
#define min(X, Y) ((X) < (Y) ? (X) : (Y)) x = min(a + 28, *p) -> x = ((a + 28), (*p) ? (a + 28) : (*p)); y = min(min(a, b), c) -> min(((a) < (b) ? (a) : (b)), c) -> .... // 產生的結果可能會和你想的不一樣
stringification(中文不知道怎麼稱呼,暫稱他字串化吧),當macro所帶的參數前面加上"#"之後,這個參數就會被展成字串,這就是stringification。 如:
#define WARN_IF(EXP) \
do { if (EXP) \
fprintf (stderr, "Warning: " #EXP "\n"); } \
while (0)
WARN_IF (x == 0);
-> do { if (x == 0) fprintf (stderr, "Warning: " "x == 0" "\n"); } while (0);
目前只有stringification,並沒有辦法轉成character。另外,stringification的優先權會高於argument expand。 如:
#define xstr(s) str(s) #define str(s) #s #define foo 4 str (foo) -> "foo" xstr (foo) -> xstr (4) -> str (4) -> "4"
token concatenation或稱token pasting,是利用"##"將兩個token組成一個token,'##'被置於兩個token之間,如:
#define COMMAND(name) {#name, name ## _command}
struct command {
char *name;
void (*f)(void);
} cmds[] = {
COMMAND(quit),
COMMAND(help),
};
->
struct command {
char *name;
void (*f)(void);
} cmds[] = {
{"quit", quit_command},
{"help", help_command},
};
variadic其實就是不定參數的function-like macro,__VA_ARGS__代表"..."(即後面所有的參數),如:
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
eprintf("%s(#%d)\n", __FUNCTION__, __LINE__)
-> fprintf(stderr, "%s(#%d)\n", __FUNCTION__, 7)
cpp也可以使用name取代__VA_ARGS__,用法上只是在"..."前面加上name,"_VA_ARGS__"則用name取代即可,如:
#define eprintf(args...) fprintf(stderr, args)
eprintf("%s(#%d)\n", __FUNCTION__, __LINE__)
-> fprintf(stderr, "%s(#%d)\n", __FUNCTION__, 7)
來看另外一個例子
#define eprintf(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
eprintf("hello\n");
-> fprintf(stderr, "hello\n", ); // error!!
這裡的問題就是如何將__VA_ARGS__前面的","在沒有參數帶入的時候刪除,答案就是"##"。
#define eprintf(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
eprintf("hello\n");
-> fprintf(stderr, "hello\n"); // correct!!
標籤:
C,
GCC - C Preprocessor
2010年6月5日 星期六
gmake之4.8 Special Built-in Target Names - .PRECIOUS
4.8 Special Built-in Target Names - .PRECIOUS
The targets which .PRECIOUS depends on are given the following special treatment: if make is killed or interrupted during the execution of their commands, the target is not deleted. See Section 5.6 [Interrupting or Killing make], page 49. Also, if the target is an intermediate file, it will not be deleted after it is no longer needed, as is normally done. See Section 10.4 [Chains of Implicit Rules], page 107. In this latter respect it overlaps with the .SECONDARY special target. You can also list the target pattern of an implicit rule (such as ‘%.o’) as a prerequisite file of the special target .PRECIOUS to preserve intermediate files created by rules whose target patterns match that file’s name.
The targets which .PRECIOUS depends on are given the following special treatment: if make is killed or interrupted during the execution of their commands, the target is not deleted. See Section 5.6 [Interrupting or Killing make], page 49. Also, if the target is an intermediate file, it will not be deleted after it is no longer needed, as is normally done. See Section 10.4 [Chains of Implicit Rules], page 107. In this latter respect it overlaps with the .SECONDARY special target. You can also list the target pattern of an implicit rule (such as ‘%.o’) as a prerequisite file of the special target .PRECIOUS to preserve intermediate files created by rules whose target patterns match that file’s name.
簡單的說就是當make在執行某個target的時候,如果make被kill或者被interrupted(ctrl+c),那麼target file就會被刪除,如果加到.PRECIOUS就不會刪除。
brook@ubuntu:~$ more Makefile
#.PRECIOUS: obj/x.o
obj/x.o:
gcc -c x.c -o obj/x.o
sleep 5;
brook@ubuntu:~$ make -f Makefile
gcc -c x.c -o obj/x.o
sleep 5;
^Cmake: *** Deleting file `obj/x.o'
make: *** [obj/x.o] Interrupt
brook@ubuntu1:~$ more Makefile
.PRECIOUS: obj/x.o
obj/x.o:
gcc -c x.c -o obj/x.o
sleep 5;
brook@ubuntu1:~$ make -f Makefile
gcc -c x.c -o obj/x.o
sleep 5;
^Cmake: *** [obj/x.o] Interrupt
brook@ubuntu1:~/excerise/Make$
標籤:
tools - make
訂閱:
文章 (Atom)
