Search code examples
cvisual-studio-codegccgcc-warning

How to turn on all warnings in GCC while using VS Code?


Recently i came across a problem written in C where there was some undefined behaviour due to which there was some segmentation error. While other people who helped me debugging it were getting warnings from their compiler which was GCC too. In my case while running that same problem in VS Code it gives no warnings and not even a single error and sadly no output. The execution starts and then closes own its own in the terminal. I use Windows 11.

I want this kinds of warnings. People who helped me got this kind of warnings


Solution

  • You should try adding -Wall -Wextra when you compile, like this:

    gcc main.c -o executable.exe -Wall -Wextra

    Those options tell compiler to be more strict and show you more warnings. You can see what exactly they do on this page