發表文章

目前顯示的是有「VC」標籤的文章

C++ compiler standard support

各種compiler https://en.cppreference.com/w/cpp/compiler_support Visual C++ Language Conformance https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance MSVC的 C++ 支援狀況 比較重要的是 C++17 std:byte 和 Windows SDK中byte 打架的解法 把_HAS_STD_BYTE定義成0 command line的話加上 -D_HAS_STD_BYTE=0 不要std::boolean的話 -D_HAS_STD_BOOLEAN =0 https://docs.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8 /source-charset:utf-8 VS2017, VS2019效能比較 https://devblogs.microsoft.com/cppblog/game-performance-and-compilation-time-improvements-in-visual-studio-2019/

Visual Studio MSVC compiler/linker options (optimization and etc)

紀錄冷門參數 有些功能看起來compiler/linker都有,因為compile和link可能不是同時做 同樣的功能兩邊都有 https://blogs.msdn.microsoft.com/vcblog/2013/09/11/introducing-gw-compiler-switch/   Compiler /Gw 消除重複或沒用到的global data https://docs.microsoft.com/en-us/cpp/build/reference/gw-optimize-global-data /Gy 消除重複或沒用到的function https://docs.microsoft.com/en-us/cpp/build/reference/gy-enable-function-level-linking /GL 可能會導致compile失敗 ex: ffmpeg 對整個程式做最佳化,要順便指定link /LTCG,才不會偵測到後再重跑增加效率 開了,/LTCG可以加開PGO(profile guided optimization),好像是自動產生數據去測試,未必是好的結果,建議測試過才決定要不要開 /GS- (Buffer Security Check) 關掉可以提高效能 ex: 很多執行時間短的function calls,檢查就會相對占用較多時間 https://docs.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check /GUARD:NO (Enable Guard Checks) 目前預設是關的,可以不用下 https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-guard-checks /favor (Optimize for Architecture Specifics) https://docs.microsoft.com/en-us/cpp/build/reference/favor-optimize-for-architecture-specifics 除了提高效能外,目前使用發現binary有變小 /O...

VC++ install, vcpkg

圖片
English installer "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" --locale=english https://github.com/Microsoft/vcpkg 更新 vcpkg remove --outdated vcpkg install <list of libraries you want available by default> See .\vcpkg help triplet for all supported targets. 只build release,可在triplet內加入 set(VCPKG_BUILD_TYPE release) 加compiler flag build lib時 VCPKG_C_FLAGS VCPKG_CXX_FLAGS https://github.com/Microsoft/vcpkg/issues/3106 安裝可加參數 cmake -E env CFLAGS="-MP -Oi -arch:AVX2"  CXXFLAGS="-MP -Oi -arch:AVX2" cmake 使用lib方法 https://github.com/Microsoft/vcpkg/blob/master/docs/users/integration.md cmake .. -DCMAKE_TOOLCHAIN_FILE=.../vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x86-windows-static https://github.com/kvirc/KVIrc/issues/2400#issuecomment-421496054 https://blogs.msdn.microsoft.com/vcblog/2016/11/01/vcpkg-updates-static-linking-is-now-available/ triplet的customization https://github.com/Microsoft/vcpk...