Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save t-mat/7e4c0ff7c5d6335d2108b7ec82f9e4da to your computer and use it in GitHub Desktop.
Save t-mat/7e4c0ff7c5d6335d2108b7ec82f9e4da to your computer and use it in GitHub Desktop.
[VC++]Visual C++ のプロジェクトに必ず追加したいオプション

Visual C++ のプロジェクトに必ず追加したいオプション

コンパイラオプション

Visual Studio のメニュー > プロジェクト > プロパティ > Configuration Properties > C/C++ > Command Line 内の Additional Options に下記を加える

/utf-8

リンカオプション

Visual Studio のメニュー > プロジェクト > プロパティ > Configuration Properties > Linker > Command Line 内の Additional Options に下記を加える

/PDBALTPATH:%_PDB%
/emittoolversioninfo:no

環境変数 _CL_

cl.exe は環境変数 _CL_ をデフォルト引数として扱う。コマンドラインでのビルドが可能な場合、これを利用することも考慮に入れる。

例えば、以下のような環境変数設定により、プロジェクトに変更せずにコンパイラオプション /utf-8 およびリンカオプション /emittoolversioninfo:no の設定が可能になる

set "_CL_=/utf-8 /link /emittoolversioninfo:no"

ただし、 clang-cl はこれらのオプションに対応していない。使用する際は _CL_ を空にしてから実行する

set "_CL_="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment