我知道我们可以使用g ++编译器将程序编译为C ++。但是g ++编译器默认为98版本。要将其作为C ++ 14运行,我们需要在终端中添加-std=c++14
。
Sublime Text因其重量轻和功能而被认为是有竞争力的编程的有价值的编辑器。在这些比赛中,时间很重要,因此在复制文本文件然后从终端运行时浪费了时间。与98相比,C ++ 14具有丰富的库和其他重要功能。因此,人们希望能够在sublime文本和C ++ 14上编译代码。
但是如何确保在Sublime Text 3中编译代码时,它会默认编译为C ++ 14?
经过一番摆弄后,我提出了以下解决方案 -
更改
"shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
到
"shell_cmd": "g++ -std=c++14 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
在构建和运行
-std=c++14
这是正确的方法吗?它被命名为单个文件 - 如果我想使用多个文件,这是否需要担心?
答案 0 :(得分:6)
最好创建一个新的构建系统,具体如下:
点击def read_from_csv(filename_queue):
reader = tf.TextLineReader()
_, csv_row = reader.read(filename_queue)
record_defaults = [[""],[0]]
image_path, label = tf.decode_csv(csv_row, field_delim=" ", record_defaults=record_defaults)
# here's where I need to read the file somehow...
image = tf.read_file(image_path) # I probably need this somewhere
print(image) # Tensor("DecodeJpeg:0", shape=(?, ?, 3), dtype=uint8)
image = tf.image.decode_jpeg(image, channels=3)
return image, label
。
这是我使用的(注意标志Tools -> Build System -> New Build System
)
-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}'"]
}
]
}
中选择它
现在,您可以使用Tools -> Build System
答案 1 :(得分:1)
通常,编辑默认文件很糟糕。 只需创建一个新的构建系统托盘 - >构建:新构建系统 在那里添加您的更改并根据需要保存。 然后,当您想要使用它时,只需选择Build With :(新建系统名称) 如果您还需要Build - Run选项,请改用此代码:
{
"cmd": ["g++", "-std=c++14", "${file}", "-o", "${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++1y '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
答案 2 :(得分:1)
编辑默认文件的最佳方法是使用PackageResourceViewer。
安装完成后,从PackageResourceViewer: Open Resource
运行command palette
命令。您将看到一个包列表,您可以导航到该列表以选择要编辑的文件。
所选文件将在新文档中打开,任何更改都将保存到位于Packages/PackageThatYouEdited/FileThatYouEdited.ext
此方法的好处是Packages
中的已编辑文件现在将覆盖sublime-package
文件中的原始文件,但原始文件将保持不变。如果您选择删除已编辑的文件,sublime-package
中的原始文件将再次处于活动状态。