简体   繁体   English

为什么 Vsc 不显示错误?

[英]Why doesn't Vsc show errors?

I am using Vsc to write my program in C, the program should return an error but nothing is shown, only the final code is provided (code = 3221225477), how can I get the error displayed?我在C用Vsc写我的程序,程序应该返回错误但什么也没有显示,只提供了最终代码(代码= 3221225477),我如何才能显示错误?

The final output is: [Done] exited with code=3221225477 in 0.569 seconds最后的 output 是: [Done] exited with code=3221225477 in 0.569 seconds

#include <stdio.h>
#include <stdlib.h>

int main(){

    char x = 'a';
    printf("%s", x);   //Error cause i'm using %s for a char
}

Ps I have already installed.Run and the C / C ++ extension Ps 我已经安装了。运行和 C / C ++ 扩展

The Microsoft C/C++ extension if configured properly ( problemMatcher in tasks.json ) should also trigger similar errors based on the compiler you select.如果配置正确,Microsoft C/C++ 扩展( problemMatcher中的tasks.json )也应该根据您的编译器触发类似的错误 select。

After investigation, you might get some help from the clangd extension.经过调查,您可能会从 clangd 扩展中获得一些帮助。

  1. Install the extension in VS Code from https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangdhttps://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd在 VS Code 中安装扩展
  2. Open your project folder in VS Code and open the source file (like main.c ).在 VS Code 中打开项目文件夹并打开源文件(如main.c )。

Then this extension should run clangd in the background and show a warning "Format specifies type 'char *' but the argument has type 'char' (fix available)".然后这个扩展应该在后台运行 clangd 并显示警告“格式指定类型‘char *’但参数的类型为‘char’(修复可用)”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM