VS Code启动:程序不存在

huangapple go评论68阅读模式
英文:

VS Code launch: program does not exist

问题

这是我的文件 "test.c"

这是我的 launch.json:

这是我的 tasks.json:

我得到了这个错误消息。它说:“launch: program '<path to program except the path seprators are crossed out "W" characters>' does not exist

你能告诉我我错在哪里吗?我已经安装了 C/C++ 扩展包、主题和 MinGW。

英文:

This is my file "test.c"

#define _CRT_SECURE_NO_WARNINGS
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

#define MAX_STACK_SIZE 100
typedef int Element;
Element data[MAX_STACK_SIZE];
int top;

void error(char str[]){
    printf(&quot;%s\n&quot;,str);
    exit(1);
}

void init_stack(){
    top = -1;
}
int is_empty(){
    return top==-1;
}
int is_full(){
    return top == MAX_STACK_SIZE -1;
}
int size(){
    return top +1;
}
void push(Element e){
    if(is_full()){
        error(&quot;스택 포화 에러&quot;);
        data[++top] = e;
    }
}
Element pop(){
    if(is_empty()){
        error(&quot;스택 공백 에러&quot;);
        return data[top--];
    }
    
}
Element peek(){
        if(is_empty()){
        error(&quot;스택 공백 에러&quot;);
        return data[top];
        }
    }
    void print_stack(char msg[]){
        print(&quot;%s[%2d]&quot;, msg, size());
        for(int i = 0; i&lt;size(); i++){
            printf(&quot;%2d&quot;, data[i]);
        }
        printf(&quot;\n&quot;);
    }
int main(void){
    init_stack();
    for(int i = 1; i&lt;10; i++){
        push(i);
    }
    print_stack(&quot;스택 push 9회&quot;);
    printf(&quot;\tpop() ---&gt; %d\n&quot;, pop());
    printf(&quot;\tpop() ---&gt; %d\n&quot;, pop());
    printf(&quot;\tpop() ---&gt; %d\n&quot;, pop());
    print_stack(&quot;스택 pop 3회&quot;);

    return 0;
}

and this is my launch.json:

 &quot;version&quot;: &quot;0.2.0&quot;,
    &quot;configurations&quot;: [
        {
            &quot;name&quot;: &quot;gcc.exe build active file&quot;,
            &quot;type&quot;: &quot;cppdbg&quot;,
            &quot;request&quot;: &quot;launch&quot;,
            &quot;program&quot;: &quot;${fileDirname}\${fileBasenameNoExtension}.exe&quot;,
            &quot;args&quot;: [],
            &quot;stopAtEntry&quot;: false,
            &quot;cwd&quot;: &quot;${fileDirname}&quot;,
            &quot;environment&quot;: [],
            &quot;externalConsole&quot;: true,
            &quot;MIMode&quot;: &quot;gdb&quot;,
            &quot;miDebuggerPath&quot;: &quot;C:\\msys64\\mingw64\\bin\\gdb.exe&quot;,
            &quot;setupCommands&quot;: [
                {
                    &quot;description&quot;: &quot;Enable pretty-printing for gdb&quot;,
                    &quot;text&quot;: &quot;-enable-pretty-printing&quot;,
                    &quot;ignoreFailures&quot;: true
                }
            ]
        }

    ]

and this is my tasks.json:

{
    &quot;tasks&quot;: [
        {
            &quot;type&quot;: &quot;cppbuild&quot;,
            &quot;label&quot;: &quot;C/C++: gcc.exe build active file&quot;,
            &quot;command&quot;: &quot;C:\\msys64\\mingw64\\bin\\gcc.exe&quot;,
            &quot;args&quot;: [
                &quot;-g&quot;,
                &quot;${file}&quot;,
                &quot;-o&quot;,
                &quot;${fileDirname}\${fileBasenameNoExtension}.exe&quot;
            ],
            &quot;options&quot;: {
                &quot;cwd&quot;: &quot;${fileDirname}&quot;
            },
            &quot;problemMatcher&quot;: [
                &quot;$gcc&quot;
            ],
            &quot;group&quot;: {
                &quot;kind&quot;: &quot;build&quot;,
                &quot;isDefault&quot;: true
            },
            &quot;detail&quot;: &quot;Task generated by Debugger.&quot;
        }
    ],
    &quot;version&quot;: &quot;2.0.0&quot;
}

and I've got this error message. It says: "launch: program '&lt;path to program except the path seprators are crossed out "W" characters&gt;' does not exist"

Can you point me where I'm wrong? I have installed c/c++&extension pack, themes, MinGW also.

答案1

得分: 1

你需要实际运行你的构建任务。请参考命令面板中的任务: 运行任务任务: 运行构建任务命令。

如果你想在启动配置之前自动运行构建任务,那么可以使用启动配置的preLaunchTask字段(详见文档以获取更多信息)。

英文:

You have to actually run your build task. See the Tasks: Run Task or Tasks: Run Build Task commands in the command palette.

If you want the build task to be run automatically before starting the launch config, then use the launch config preLaunchTask field (see the docs for more info).

huangapple
  • 本文由 发表于 2023年5月28日 23:05:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76352126.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定