2008年5月31日 星期六

在讀 C++ Templates: The complete guide 時, page 107講到function template 的 overload時

有所謂的SFINAE原則(替換失敗並非錯誤) 舉出了2個例子


template void f(int (&)[24/(4-I)]);

template void f(int (&)[24/(4+I)]);


int main()

{

&f<4>; <-- error C2568: 'identifier' : unable to resolve function overload

}


//在VC9 (VS2008)是ok的 會顯示錯誤



template int g() { return N; }

template int g() { return *P; }


int main()

{

return g<1>();


}


// 在VC9 一樣無法過關

出現以下錯誤訊息

error C2440: 'specialization' : cannot convert from 'int' to 'int *const '

error C2973: 'g' : invalid template argument 'int'

error C2668: 'g' : ambiguous call to overloaded function

2008年5月30日 星期五

extern "C" 大不同

extern "C" func();

和 extern "C"

{

func();

}


完全不一樣


extern "C" func(); 宣告而已 有這個函數

extern "C" { func(); } 是定義 採用C Linking ( C decoration )

C/C++ Mixed 的小問題 C2275


error C2275 ( illegal use of this type as an expression ) 是變數宣告沒放在開頭的問題 ...

DLL Viewer

在做JTAG的實驗時 如果以Windows XP和Parallel port cable開發程式

第一步就是要克服在Win XP下對port Direct I/O 的問題


Google了一下 發現Inpout32.dll 這個函式庫

但是要看它到底輸出了哪些函式 函式的確切型別和名稱

就需要一個好用的DLL Viewer了 ;-)

(雖然在VS2008 Console 下dumpbin之類的utility也可以做到)



不過好像看不到Export Function的參數

不知道要如何才能得知 Export funtion 的參數

VS2008的問題

今天用VS2008編譯了一個小程式 看到Output 視窗中多了一個Generating manifest的東西

就跑到Project Property Page裏面去把它關掉 問題來了 關掉之後就無法debug或run 程式

Visual Studio 2008 會出現mfc90ud.dll 無法載入的錯誤 後來又把manifest打開才回復正常


用了偉大的G神查了一下 原來在VS2008 manifest是必備的 無法移除的