好文備份
__attribute__((constructor(PRIORITY)))
__attribute__((destructor(PRIORITY)))__attribute__((visibility("default")))
好文備份
__attribute__((constructor(PRIORITY)))
__attribute__((destructor(PRIORITY)))__attribute__((visibility("default")))
http://stackoverflow.com/questions/201101/how-to-initialize-an-array-in-c
If your compiler is GCC you can use following syntax:
int array[1024]={[0...1023]=5};
//================================================================================================================
// description, initialize a array
copy from
http://stackoverflow.com/questions/3553296/c-sizeof-single-struct-member
Although defining the buffer size with a #define is one idiomatic way to do it, another would be to use a macro like this:
#define member_size(type, member) sizeof(((type *)0)->member)
and use it like this:
//========== debug ==================
引用及備分自以下網址
http://www.jeffhung.net/blog/articles/jeffhung/1013/
在程式寫作的過程中,通常我們會需要輸出一些訊息,方便我們瞭解程式的運作情形,以便偵錯。因為這些訊息,對程式的真正使用者,也就是我們開發者的 客戶,並沒有意義。是故,通常我們會將程式分成測試版 (debug version 或 debug mode) 或釋出版 (release version 或 release mode),然後只在測試版裡輸出這些訊息,而在釋出版裡完全抑制這些訊息的輸出。
第零版:dprintf_v0.c
出處在下面的網址, 寫的太好 我備分而已
位結構
http://hi.baidu.com/dirac/blog/item/daf8980e62ba01e437d12245.html
class CTest{
std::ostream debug_message;
explicit CTest():debug_message( cout.rdbuf() ){} ;
~CTest(){};
void Print(){

原文出處
結構的對齊(Struct Member Alignment)
變數的宣告,會配置其所需的記憶體。每種變數所需的大小不一樣,比如說char是1 bytes,int 是4 bytes,double則是8 bytes。
如果是這樣,那這些大小在記憶體中是如何擺放呢?是直覺的一個接一個放嗎?