2008年12月17日 星期三

CNN Top news - Passengers saved from dangling gondolas after tower snaps

Passengers have been rescued from a gondola dangling over a freezing creek after the tower snapped in half Tuesday at a ski resort near Whistler, British Columbia.

在Whistler附近的滑雪場纜車支柱於週二發生倒塌意外,一台纜車懸掛在結冰的河川上,上面的乘客已經被救出。


gondola [] n. 纜車

dangle[] v.i. 懸蕩
His keys dangled from a chain.

snap [] v.t. 咬;折斷
The dog snapped my leg.
He snapped the stick in two.


為什麼我馬上想到貓纜呢......科科

2008年12月15日 星期一

CNN Top news - Iraqi journalist throws shoes at Bush in Baghdad

"Hurling shoes at someone, or sitting so that the bottom of a shoe faces another person, is considered an insult among Muslims."

對於回教徒來說,往人身上丟鞋子,或是坐著將鞋底朝著人,都是一種侮辱。


hurl [] v.t. 猛力投擲
He hurled all the books out of the window.

insult [] n. 侮辱
Your sympathy for me is an insult to my pride.

布希去巴格達友善訪問,被一個記者丟鞋......
原來回教徒不能忍受別人的鞋底啊(筆記)

參考新聞

2008年12月9日 星期二

On the house

這句片語呢,跟字面上的意思完全無關!!
會提到這句片語,是因為魔獸世界裡面有一個NPC有一句台詞,而台灣的智XD翻譯成

"這是在屋頂上的"

下一句是

"既然是免費的......"

大家應該都覺得上下文完全無關吧...囧rz

第一句的英文原文是 "This is on the house"
而on the house絕對不是在屋頂上......應該是免費的意思!

These drinks are on the house.
這些飲料是免費的。

C/C++ Name mangling

相信常在使用一些C library的人,常常會在標頭檔看到以下的程式碼

#ifdef __cplusplus
extern "C" {
#endif

簡單講,這是為了避免C++的name mangling造成linker無法link到正確的symbol。

C++支援function overloading,所以下列兩個function可以同時存在

void foo(int a);
void foo(double a);

這是因為C++ compiler會將function name"變形",例如:

void func_int(int a);
void func_double(double a);

這樣就沒有衝突的情形了。
但是用C compiler所編譯出來的object,裡面的symbol可是沒有什麼name mangling的
所以linker當然就沒辦法找到C++變形過後的symbol,就出現unresolved symbol的error了
因此,C++提供了extern "C"這個辦法,只要用extern "C"包起來的,compiler就知道裡面的symbol都是"unmangled"的,例如:

extern "C"
{
#include "c_library.h"
}

如此一來,就可以順利link C compiler所編出的object了

另外,各家compiler實做name mangling的方式也不一樣
所以用VC編好的library,沒辦法直接拿去跟gcc的一起link喔,不過這總比因為不相容造成一堆奇怪的問題好多了

參考資料 http://en.wikipedia.org/wiki/Name_mangling