【发布时间】:2019-10-22 14:32:59
【问题描述】:
当我右键单击运行代码并在我的用户设置中的终端中运行时,我收到这些错误。
At line:1 char:63 + ... "c:\Users\Josh\Documents\Programming\Learning to Program\" && g++ Exe ... + ~~ The token '&&' is not a valid statement separator in this version. At line:1 char:99 + ... \Learning to Program\" && g++ Exercise36.cpp -o Exercise36 && "c:\Use ... + ~~ The token '&&' is not a valid statement separator in this version. At line:1 char:102 + ... ercise36 && "c:\Users\Josh\Documents\Programming\Learning to Program\ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expressions are only allowed as the first element of a pipeline. At line:1 char:160 + ... "c:\Users\Josh\Documents\Programming\Learning to Program\"Exercise36 + ~~~~~~~~~~ Unexpected token 'Exercise36' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidEndOfLine
直到今天我一直在编译,我做了一些谷歌搜索并开始在终端中输入我自己的命令,而不仅仅是运行代码。
我开始用-and 替换&& 并遇到不同的问题。这就是命令现在的样子。
"c:\Users\Josh\Documents\Programming\Learning to Program\" -and g++ Exercise36.cpp -o Exercise36 -and "c:\Users\Josh\Documents\Programming\Learning to Program\"Exercise36
这是我得到的错误。
Set-Location : Parameter cannot be processed because the parameter name 'o' is ambiguous. Possible matches include: -OutVariable -OutBuffer. At line:1 char:87 + ... \Programming\Learning to Program\" -and g++ Exercise36.cpp -o Exercis ... + ~~ + CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.SetLocationCommand
我正在使用 GNU 开源编译器,这是我在编译时遇到的第一个问题,因为我意识到在编译之前必须先保存。我正在运行一个简单的字符串,它将所有字符从从 C++ Primer 程序的终端读取的字符串中更改为 X。任何帮助将不胜感激。
【问题讨论】:
-
当我将“&&”更改为“;”时我不再收到错误,但我确实得到了与我预期不同的结果,这是我需要更改 json 文件的东西吗?
标签: c++ powershell visual-studio-code g++