-
Recent Posts
Recent Comments
Categories
Links
Monthly Archives: March 2018
MSVC debug build
在VC++的設定: C/C++若有定義_DEBUG 則需注意link應該link MTd or MDd 因為有些function 如_free_dbg是在定義_DEBUG時會被編譯(參考<crtdbg.h>) 此時如果link到release版的MT or MD,則會出現unresolved link 另外,這個錯誤訊息也是因為_DEBUG混用造成的 error LNK2038: mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’ in … 在<yvals.h≶(一些c++ std header會間接引用) #ifdef _DEBUG #define _HAS_ITERATOR_DEBUGGING 1 #else #define _HAS_ITERATOR_DEBUGGING 0 #endif … Continue reading
Posted in Tips
Leave a comment
show gcc predefined macro
gcc -dM -E – < /dev/null 這邊僅列出有__STDC的作為範例 #define __STDC_HOSTED__ 1 #define __STDC_UTF_16__ 1 #define __STDC_IEC_559__ 1 #define __STDC_ISO_10646__ 201505L #define __STDC_NO_THREADS__ 1 #define _STDC_PREDEF_H 1 #define __STDC_IEC_559_COMPLEX__ 1 #define __STDC_VERSION__ 201112L #define __GNUC_STDC_INLINE__ 1 #define __STDC_UTF_32__ 1 #define __STDC__ 1 … Continue reading
Posted in C Language
Leave a comment
C99 _Bool
C99定義了關鍵字 _Bool, 又另外新增了stdbool.h 將 #define bool _Bool #define true 1 #define false 0 為什麼用_Bool這樣看起來有點奇怪的命名而不直接定義bool? 最主要的原因是因為在c89 bool並非保留字, 因此在擴展規範時只能從reserved identifier下手了 在c89的規範 7.1.3第一項提到 All identifiers that begin with an underscore and either an uppercase letter or another underscore are always reserved for any … Continue reading
Posted in C Language
Leave a comment
gcc flags about c standard
以gcc 5.1.0為例 https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Standards.html The default, if no C language dialect options are given, is -std=gnu11. 如果要採用c89(or c90) 可使用下面的選項之一 -ansi -std=c89 -std=c90 -std=iso9899:1990 這樣會關掉一些gnu extension 如果要對應C標準的要求 則再加上 -pedantic or -pedantic-errors 即 -std=c89 -pedantic
Posted in C Language
Leave a comment
mount tips
show export list showmount -e #local showmount -e 192.168.1.10 #remote mount -t nfs 192.168.1.10:/XXXX /YYYY nfsstat -m #查看nfs mount相關信息 mount -t cifs -o admin,passwd //192.168.1.10/base /mnt mount -t cifs -o username=admin //192.168.1.10/base /mnt VBoxManage storageattach #VBOXNAME –storagectl “SATA” –port 0 … Continue reading
Posted in System Administration
Leave a comment
ssh亂碼
ssh進Mac時發生亂碼,可先檢查locale 是否設定成正確 (打locale即可)一般是utf8,因為linux ssh client預設會forward locale env variable可參考 /etc/ssh/ssh_config SendEnv LANG LC_* LANG=”en_US.UTF-8″LC_COLLATE=”en_US.UTF-8″LC_CTYPE=”en_US.UTF-8″LC_MESSAGES=”en_US.UTF-8″LC_MONETARY=”en_US.UTF-8″LC_NUMERIC=”en_US.UTF-8″LC_TIME=”en_US.UTF-8″LC_ALL=”en_US.UTF-8″ 如果不是utf8則可以 export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 也可設定在~/.bashrc
Posted in System Administration
Leave a comment
boost library naming
參考: http://www.boost.org/doc/libs/1_66_0/more/getting_started/windows.html#library-naming https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx 另外 boost/config/autolink.hpp裡有提到lib naming的規則 BOOST_LIB_PREFIX + BOOST_LIB_NAME + “_” + BOOST_LIB_TOOLSET + BOOST_LIB_THREAD_OPT + BOOST_LIB_RT_OPT “-” + BOOST_LIB_VERSION On Windows, only ordinary static libraries use the lib prefix; import libraries and DLLs do not. windows上 static library才有lib prefix … Continue reading
Posted in Library
Leave a comment
nodejs request iconv
在使用nodejs request抓取網頁時,如果需要進行轉碼,則須注意request的callback中body是string or buffer 對於Big5來說 如果轉成javascript string, 此時body在iconv(由big5=>utf8)會失敗。 javascript string假設input是utf8 需要強制body保留原始bytes request({ url: …, method: ‘GET’, encoding: null }, function (err, resp, body){ //body is buffer now }); 在說明文件有提到 encoding – encoding to be used on setEncoding of response data. … Continue reading
Posted in nodejs
Leave a comment
ffmpeg build on windows
根據 https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC 的說明 這邊使用VS2015, 配合msys 如需要啟用yasm選項 => http://yasm.tortall.net/Download.html download yasm.exe => C:\Windows yasm選項 deprecated WARNING: The –enable-yasm option is only provided for compatibility and will be removed in the future. Use –enable-x86asm / –disable-x86asm instead. msys2 with vs support msys2 … Continue reading
Posted in Library
Leave a comment