由於 Phonon 在運作上會把讀到的東西轉交給它的後端,如果你已經有了一個原始的 PCM 資料,那麼在餵給 Phonon 時要記得填上 wav 的 header,才能讓後端辨識並找到合適的方式開啟它。
TAG
首都機能移轉
(2)
歌詞
(2)
靠北文
(40)
戲言
(30)
糟糕
(7)
ACG
(23)
Assembly
(2)
Boost
(2)
C
(31)
C++
(69)
CMake
(4)
CSIE
(67)
Debian
(34)
Design_Pattern
(2)
Django
(1)
Eclipse
(1)
en_US
(13)
FFmpeg
(3)
FoolproofProject
(26)
FreeBSD
(2)
Git
(4)
GNU_Linux
(65)
IDE
(5)
Java
(11)
JavaScript
(19)
KDE
(15)
Khopper
(16)
KomiX
(3)
Kubuntu
(18)
Life
(1)
Lighttpd
(2)
Mac_OS_X
(2)
Opera
(1)
PHP
(2)
PicKing
(2)
Programing
(21)
Prolog
(1)
Python
(7)
QSnapshot
(2)
Qt
(30)
Qt_Jambi
(1)
Regular_Expression
(1)
Shell_Script
(7)
Talk
(98)
VirtualBox
(7)
Visual_Studio
(13)
Windows
(18)
zh_TW
(36)
2010年6月12日 星期六
2010年5月22日 星期六
Templates needs no "__dllspec"
同之前提到的, Visual C++ 要做 export/import symbol 的動作才能連結 dll, 但是 template classes 和 functions 是不需要的 ... 原因很單純, 就是 template 在 Visual C++ 是原地展開的, 不需要再額外做 symbol 的定義[?].
類別:
C++,
Programing,
Visual_Studio,
Windows,
zh_TW
2010年4月2日 星期五
Converting literal
#include <stdio.h>
int main() {
for( char tmp[1024]; fgets( tmp, sizeof( tmp ), stdin ) != NULL; ) {
for( unsigned char * c = tmp; *c; ++c ) {
if( *c == '\n' ) {
printf( "\n" );
} else {
printf( "\\x%02X", *c );
}
}
}
return 0;
}
類別:
C,
CSIE,
Programing,
zh_TW
2010年3月14日 星期日
Using UTF-8 literals in source code
直接在 code 裡打 UTF-8 字元在有的 IDE 會無法辨識,像是 Visual C++ 2005 和 2008 堅持使用 locale 的編碼來解讀 source,導致換 locale 就會編譯失敗。
這種時候沒什麼有效的解決方法,就是用 hex escape 字元啦 ...
這種時候沒什麼有效的解決方法,就是用 hex escape 字元啦 ...
/* 正體中文 in UTF-8 */ const char * utf8 = "\xE6\xAD\xA3\xE9\xAB\x94\xE4\xB8\xAD\xE6\x96\x87";很煩,很難讀,不過至少所有的字元都保證在 C / C++ 的標準字元集裡;只是最好在旁加上註解說明那應該是什麼字,否則很難維護。
類別:
C,
C++,
CSIE,
Programing,
zh_TW
2010年3月12日 星期五
Forward declaration with template parameters
在避免編譯時間拉長的時候,forward declaration 是個很好的選擇。但是有一些時候你無法使用 forward declaration,一個是該型別其實是個 typedef 的時候,另一個是當這個型別用在 template parameter 的時候。
由於 template class 經常是 inline 的,所以它可能在 header 就必須要知道 template parameter 的大小或成員這些細節。這導致你必須要 include definition 或是改用 pointer。
你說 smart pointer? 不會吧?(笑)
由於 template class 經常是 inline 的,所以它可能在 header 就必須要知道 template parameter 的大小或成員這些細節。這導致你必須要 include definition 或是改用 pointer。
你說 smart pointer? 不會吧?(笑)
類別:
C++,
CSIE,
Programing,
zh_TW
2010年3月10日 星期三
Export the symbols of QtSingleApplication
現在 Qt Solution 只能在 git 上取得了。
若想要編成 library,在 configure 參數加上 -library 即可:
若想要編成 library,在 configure 參數加上 -library 即可:
configure -library qmake make # or nmake for MSVC真正需要的 header 只有 QtSingleApplication, qtsingleapplication.h, qtcoresingleapplication.h。
The following content is obsolete. Latest update: 2011/04/23
Qt Solutions 的慣例似乎是把它內附的 pri include 到 qmake 的專案檔內,直接把原始檔包進去編譯,而不會做出封裝檔[?]。但是這種做法只適用於用 qmake 管理的專案檔內,且編譯時間可能會拉長。如果想弄出封裝檔,就要自己對它作一點手腳。
以 QtSingleApplication 為例,可以對 buildlib/buildlib.pro 動手腳。這個設定主要是給 dynamic loading 使用的,只要在
CONFIG 加上 shared 就可以了。
-CONFIG += qt dll qtsingleapplication-buildlib +CONFIG += qt dll qtsingleapplication-buildlib shared
2010年2月15日 星期一
Create source groups in Visual C++ solutions with CMake
使用 qmake 時,Visual C++ 的方案會自動把產生的檔案(e.g.: ui_*.h, moc_*.cpp ... etc.)歸類到 Generated Files,讓原始碼樹看起來比較清爽。但是 CMake 不會幫你做這件事,專案一大就會讓這些不必修改的檔案佔滿整個專案。
但是 CMake 其實是可以做到的,使用 SOURCE_GROUP 巨集就可以建造一個群組,把原始碼組織起來。過濾的方式有二:使用 regular expression,或是直接指明檔案路徑。以下是範例。
# 明指 moc, rcc, uic, qm 檔案為 Generated Files
source_group("Generated Files" FILES ${MOC_SOURCES} ${RCC_RESOURCES} ${UIC_HEADERS} ${QM_FILES})
# 使用 RE 把資源檔找出來
source_group("Resource Files" REGULAR_EXPRESSION .*\\.rc)
# 使用 RE 把 Designer forms 歸類在 Form Files
source_group("Form Files" REGULAR_EXPRESSION .*\\.ui)
注意 regular expression 要跳出 \。
類別:
CMake,
CSIE,
IDE,
Programing,
Visual_Studio,
zh_TW
2010年2月13日 星期六
Multiple processes building with Visual C++
MinGW32 的 make 好像還沒實作 --jobs 的功能 ... 反正各平台都有很多狗屁倒灶的鳥事啦。
類別:
C,
C++,
CSIE,
IDE,
Programing,
Visual_Studio,
Windows,
zh_TW
訂閱:
文章 (Atom)