跳到主要內容

發表文章

目前顯示的是 2017的文章

PDB Debug Info on Windows and DragonEgg

最近一期的 LLVM Weekly 的文章內容提到2則新聞,一則是 LLVM on Windows now supports PDB debug info ,另一則是 DragonEgg has been updated to work with GCC 8.x and LLVM 6.x 。 第一則所提到 PDB 的這個專有名詞, LLVM 的 The PDB File Format 這一篇文章有詳細的介紹, llvm-pdbutil 的指令 如下: Have clang-cl invoke lld automatically clang-cl -fuse-ld=lld -Z7 -MTd hello.cpp Invoke clang-cl and lld separately. clang-cl -c -Z7 -MTd -o hello.obj hello.cpp lld-link -debug hello.obj 在 LLVM Blog 寫道: And to leave you with something to get you even more excited for the future, it's worth reiterating that all of this is done without a dependency on any windows specific api, dll, or library.  It's 100% portable.  Do I hear cross-compilation?   對於在 Windows 系統開發的一些程式碼,可以獨立出來,達到真正跨平台的目標。 第二則是 大陸武漢科大 Leslie Zhai 將 DragonEgg 移植 到 GCC 8.x and LLVM 6.x 版本,他說: I am migrating DragonEgg to GCC v8.x and LLVM v6.x just for fun and learn . Clang 已經相當成熟, 而且對於 Fortran language 支援 LLVM 已經有前端的 flang 專案 可以使用,有人就質疑:為何還需要維護 DragonE

Buck - a new build system

各種程式語言有不同 支持 的 build tools,例如 Javascript 的 glup, grunt, ..., etc. Java 的 ant, maven, gradle, ..., etc. C/C++ 常用的 make, cmake, ..., etc. 而 Buck 是一個新的 build tools ,主要提供一些主流的語言,包括 C/C++, Python, Java, D, React Native, Android, OCaml,特別的它採用的幾個重要的技術: Hashing: 版本控制時,使用 Hashing 來處理,在專案開發階段,不斷地測試是必然的,而僅有少部分需要再度 rebuild,使用 Hashing 來處理差異是很聰明的作法 Parallel: 在 multi-core 的架構下的軟體,支援 Parallel 可以加快 build 的處理速度 Buck 是 facebook 所開發的,是 open source code 的 project,支援不同的作業系統,目前正在開發大型專案的程式設計師,不妨可以一試,看看是否有加快 build 的速度。

發生在 C++ Standard Library 的恐怖事件

在 Twitter 上看到一則 " The Horror in the Standard Library " 這麼聳動的標題,不改好奇的個性,當然要讀他到底在說些什麼?摘錄文章幾個要點: We tried valgrind , dmalloc , the Microsoft Visual Studio memory profiler (yes we tried running it in Windows via an elaborate shim just to use this), and glibc's built-in memory tracing . Nothing worked. It's leaking but it's not. It's leaking but the debugger says no memory was lost.  The default allocator in the standard C library is designed for an acceptable trade-off between memory use and performance under ordinary work loads, but it doesn't always perform ideally in aggressively multithreaded or very high throughput applications. Luckily there are very highly regarded drop-in replacements like jemalloc . Trembling with anticipation that maybe... just maybe... I'd found the answer... I dropped in jemalloc and ran the test. We now have code in production (in ZeroTier Central) that force disables libstdc++ allocation pools via the above environm

CppCast 的 News

在 CppCast News 當中有兩則訊息: The C++ Annotations, a free up-to-date learners book/reference manual Choosing "Some C++" Over C 第一則是一本古老以前就發表在網路上的 C++ 書籍,內容隨著 C++ 標準不斷的更新,不會尚失新語法的一本C++書籍。 第二則內容簡略、快速的瀏覽以後,如同作者的第一段話:maybe I should have called this “C++ for Lovers of C,”,內容利用 curl, one of the most popular HTTP client libraries 當作例子,說明 C 語言在處理複雜問題時的困境,如果可以把 C 當作底層,當作 subset ,而對 C++ 作些許的限制,是這一篇文章所討論的問題。

推動資訊教育的省思

最近國內教育單位積極想要推動所謂資訊教育,特別提到國、中學的學生希望能學習程式設計的邏輯思考能力,報紙說,資訊的師資是足夠可以應付國、中學課綱的轉變,或許有人力可以上台教導國、中學的學生,也當然要有人力上台教程式設計,重要的是:能夠提升多少學生程式設計的能力呢? C++ father: B Stroustrup 於 January 201 在 CACM 發表 What should we teach software developers? Why? 的這篇文章中,指出學界與工業界之間脫鉤的問題;國外對於程式設計邏輯思考能力的推動,很早以前就已經開始實施,且從小學就教育學生,一系列的紮實訓練,造就許多實務型的大學生,反觀國內,資訊相關科系畢業的大學生,有多少人會寫程式?曾經遇到一位國立科技大學資訊相關科系的畢業生,就連 簡單的HTML 語法都不會,僅會寫 Microsoft 內建的 Macro,又學校內僅會惡鬥,只管誰是谁的人?哪有人會管學生學習的成效,教出僅會寫 Microsoft Macro 就洋洋得意、趾高氣揚的這樣學生,是正常的結果。諸不知一山還有一山高,想想 Eric Niebler 在他自己的網站寫著:Judge me by my C++, not my WordPress 這句話吧。 唉,感嘆! 這篇文章值得國內教育單位深思。

Visual Studio 對於 C++ 的 Debugging and Diagnostics

Visual C++ Team Blog 發表  C++ Debugging and Diagnostics 文章,內容包括: Breakpoints and control flow Data inspection and visualization Diagnostic tools and performance profiling Debugging processes and devices Multi-threaded debugging Edit and continue Other resources Visual studio 最迷人的地方就是 Debugging 的功能,最近隨著 C++ 標準的更新,以及 C++ 標準協會的 Chairman -- Herb Sutter任職在 Microsoft,Visual Studio 對於 C++ 的支援新標準的程度相當高,是在 Windows OS 平台開發 C++14 or C++17 程式碼可選擇的一種 IDE。  

kotlin:一個跨平台的程式語言

從 LLVM Weekly 中的 [1] 得知 JetBrains 的 kotlin-nativ e 這個專案,主要在致力於不需要 VM 的跨平台程式,它是以 LLVM 作為背後基礎,可以轉換成不同平台[1]: Kotlin/Native uses the LLVM compiler infrastructure to generate machine code. In this preview, we support the following target platforms : Mac OS X 10.10 and later (x86-64) x86-64 Ubuntu Linux (14.04, 16.04 and later), other Linux flavours may work as well Apple iOS (arm64), cross-compiled on MacOS X host Raspberry Pi, cross-compiled on Linux host Kotlin/Native 專案是新的專案,許多程式碼都尚未完成,不過是一個可以期待的專案。 kotlin 是什麼呢?在 kotlin 官方網站 標題寫著: Statically typed programming language for the JVM, Android and the browser kotlin 這個語言是由 JetBrains 這家公司已 Open Source 的方式所開發的專案,這家公司對自己本身而言,並不陌生,只是 kotlin 這個語言,卻是今天才知道,結合 OO 與 functional 語言的特性,似乎相當吸引人;倒是讓自己覺得,在資訊科學的領域,技術、知識、語言等,不斷的推陳出新,不須要對於任何新技術或語言都能夠了解,唯有精通某一種技術、語言的人,才能生存於這個資訊科學的領域當中。 ps: JetBrains 的 IntelliJ IDEA Community Edition 可以從 JetBrains 網站下載 ------------------------------------- [1] Kotlin/Native Tech Preview: Kotlin without a VM

用 reveal.js 撰寫 slide 的紀錄

採用 HTML Slide 已經多年,對於 reveal.js 這個 Framework 來撰寫 slide 已經很容易上手,最近某一門課程需要使用 Math 的公式,想使用 LaTeX 語法,原本想使用 slidify 這個整體性的開發環境來處理,不過, slidify 內部的 reveal.js framework 所產出的 slide 樣式卻跑得很離譜,沒有時間,只好再回到從 reveal.js github 網站所下載的原始程式碼來製作上課的 slides,這段期間, reveal.js 的套件也更新的版本,隨著版本的更新,這次也同時更新新的原始程式碼,另外,也對於以前想要調整的部分及其他的設定做了一些修改,修改的紀錄如下: 原始程式碼不再做內部的修改,直接下載 reveal.js 原始ˇ程式碼,修改成 reveal.js.tw 目錄,然後存到 slides 的目錄中 在 css 目錄中新增 style.css 來修正字型及英文字的效果,例如 font-variant:small-caps; 採用 markdown language 來撰寫 slide image 使用 <img> 來處理,並且在個別的 img 標籤內設定 margin-left: 20px 來處理沒有邊界的問題 以後其他的設定,全部都設定在 style.css 內部,不要再修改原始程式碼

live code in blog

KLIPSE 是一個可以產生互動式程式碼的網頁套件,換言之,在網頁上顯示你的程式碼,可以讓觀賞者修改並且輸出程式碼的結果。與其他顯示原始程式碼的 javascript 套件不同之處在於 live 與 interactive,live 的功能可以即時顯示程式碼的結果,interactive 讓使用者可以修改,因此,使用者可以在網頁、部落格上面修改程式碼,並且即時顯示修改後的結果。實際安裝測試,確實可以達到上面所提到的效果。 在 KLIPSE 文件有一段話: In order to integrate the klipse plugin on a blog, library documentation or any other web page, add the following javascript tag at the end of the page body according to the language of the code snippets: 必須要安裝在網頁 body 標籤底部,實際測試時,只需將下列這一段程式碼放到最後:   < script src = " https://storage.googleapis.com/app.klipse.tech/plugin_prod/js/klipse_plugin.min.js " ></ script > 另外兩個重要連結為: < link rel = " stylesheet " type = " text/css " href = " https://storage.googleapis.com/app.klipse.tech/css/codemirror.css " > < script > window . klipse_settings = { selector_eval_js : ' .language-klipse-cpp ' , // css selector for the html elements you want to klipsify }; </

Using Clang++ in CMD

LLVM Project 的 Clang++ 無法使用 GCC 的 c++ standard library,在 Johannes Peter 的 Installing clang++ to compile and link on Windows : Part 2 文章介紹如何在 command line 中可以 include <iostream> 來 compile C++ 程式碼,主要是要使用文章所提及的 clang 3.7.0 (release candidate 3) 64 bit 這個版本,這個版本的 clang++ 是 Target: x86_64-w64-windows-gnu,注意:不是目前3.9 for windows-msvc 版,因此,下載時需要注意版本。依照文章的設定步驟,可以在 cmd 中編譯 C++ 程式,在 stackOverflow 的問題 ,是相同的問題,如果需要更新的版本,可以選擇使用 clang-cl 或者 msys 環境下的設定方式。 設定的注意事項: 需要下載 文章內連結的 mingw64 版本,放置在 c:\ 中 如果不需要編譯 win32 版本的程式,不需要下鮺 mingw32 版本 需要下載 clang 3.7.0 (release candidate 3) 64 bit 這個版本 設定所有的環境變數 執行 setgcc64.bat 檔 切換到 workspace 執行 clang++ main.cpp -o main.exe -std=c++14