Compiling program as c++ 14 in Sublime Text 3 as default

前端 未结 3 1457
执念已碎
执念已碎 2021-01-12 07:48

I know that we can compile program as C++ using g++ compiler. But g++ compiler defaults to 98 version. To run it as C++ 14, we need to add -std=c++14 in termina

3条回答
  •  迷失自我
    2021-01-12 08:10

    It's better to create a new build system, here's how:

    Click on Tools -> Build System -> New Build System.

    This is what I use (notice the flag -std=c++14)

    {
     "cmd":["bash", "-c", "g++ -std=c++14 -Wall '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"],
     "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
     "working_dir": "${file_path}",
     "selector": "source.c, source.c++",
     "variants":
     [
       {
         "name": "Run",
         "cmd":["bash", "-c", "g++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
       }
     ]
    }
    

    (I believe you can just use the line you already have and save it to a new build system file.)

    Now save the new build, select it in Tools -> Build System.
    And now you can build and run with CTRL + B

提交回复
热议问题