8
5

More than 3 years have passed since last update.

【UE4】C++標準バージョンの切り替え方法

Posted at

最初に

この記事はVisual Studio 2019にIDEを設定してプロジェクトがサポートするC++標準のバージョンを変更することを記事にしたものとなります。間違いや更に良い方法があった場合にはそっとTwitter( @ろっさむ )やコメント、修正リクエストなどでお知らせ頂けるととても有難いです。

作業環境

記事内で使用する作業環境は以下の通りとなります。

  • Unreal Engine:4.23.1
  • Visual Studio:Community 2017 or Community 2017 for Mac or Enterprise 2019

Visual Studio 2019を標準IDEに変更する

左上メニューのEditorからEditor Preferences...を開き、Source CodeからSource Code EditorVisual Studio 2019に変更してください。

image.png

この変更に伴って、UE4ではVisual Studio 2015でのサポートを廃止しています。強制的にコンパイルする方法もありますが、基本的には2017以降を使用する方がよいでしょう。

使用するC++バージョンを設定する

Visual Studio のバージョン次第ではC++のバージョンも最新のものを指定することができます。

先ほどの項目でVS2019を使用しているのであれば、C++の最新バージョン(現在だと20の一部サポート)を使用できるように変更することができます。

C++のバージョン指定はプロジェクト名.Target.csでプロパティCppStandardの変更の記述で行います。

image.png

// Fill out your copyright notice in the Description page of Project Settings.

using UnrealBuildTool;
using System.Collections.Generic;

public class TEATarget : TargetRules
{
    public TEATarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Game;

        ExtraModuleNames.AddRange( new string[] { "TEA" } );

        // 14ならCppStandardVersion.14;
        // 17ならCppStandardVersion.17;
        CppStandard = CppStandardVersion.Latest;
    }
}

参考

8
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
5