Visual Studio Code 属性控制台不允许错误

6
我刚开始学习编程,正在做一本书上的练习题,卡在了求三角形面积的问题上。出现了"不允许使用控制台"的提示。这是由于math.h库引起的吗? 因为同样的代码在online-gdb上完全可以运行。

Image show's the error

这里是 launch.json 的内容。

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "gcc - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "console": "externalTerminal",
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: gcc build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

另外注意,在使用 sqrt(mult) 之前要检查 mult >= 0,即它是一个实三角形。 - Weather Vane
@WeatherVane 如果它们中没有任何一个是负数,那就是正确的。 - Antti Haapala -- Слава Україні
1
@AnttiHaapala 不要用1、1、3这样的边长,因为它们无法组成三角形。文本中有一个地方写着“矩形”,但公式和输出是针对三角形的。 - Weather Vane
哦,我尝试了4、5、6作为边长。 - Rehan Aziz
1
@WeatherVane 哦,没错 :D ENOCOFFE - Antti Haapala -- Слава Україні
显示剩余4条评论
4个回答

5

替换

"console": "externalTerminal"

使用

"externalConsole": true

似乎自动生成的launch.json文件不支持"console"属性。不过这个方法可以帮我消除警告信息。


1
这是我得出的相同解决方案。我在Microsoft文章中找到了解决方案:使用GCC入门。有人知道是哪个软件负责自动生成这个launch.json吗?我想发布一个问题或查看是否已经发布了一个问题。 - Dr. Dan
6
尝试使用 "externalConsole": true 会给我类似的警告: 属性 externalConsole 不被允许。 - ChrisCrossCrash

0
请参考此链接 https://code.visualstudio.com/docs/editor/debugging

"console": "integratedTerminal"

这个选项不会打开外部终端,并且会在 vscode 终端中捕获输入。

目前还有另外两个可用的值:"internalConsole" 和 "externalTerminal"


0

嗯,现在我收到了 "不允许使用属性externalConsole"


0
如果没有任何选项起作用,尝试使用 "terminal": "external"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接