Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Setting Up  ›  Lesson

Code Editors and IDEs

Code Editors / IDEs 10 minAn editor or IDE makes writing C faster through highlighting, completion and live errors from a language server, but the compiler you installed still does the real building.

Code Editors and IDEs

You can write the whole greenhouse logger in a plain text editor, and plenty of experienced C programmers do. A good setup, though, shows mistakes the moment you type them, completes long names, and builds with one key. The skill is knowing which part does what.

The rule

The editor shapes the text; the compiler decides whether it is C.

The popular choices:

Tool What it is How it understands C
VS Code Free editor with extensions Microsoft's C/C++ extension, or the clangd extension
Vim / Neovim Keyboard-driven terminal editors A language server such as clangd (Neovim has an LSP client built in)
CLion Full IDE from JetBrains Built-in analysis, CMake projects
Visual Studio Full IDE on Windows MSVC and its own analysis

A language server is a background program that reads your code the way a compiler does and reports errors, warnings and completions to the editor. clangd is the common one for C, and it works the same in VS Code, Neovim and many other editors.

The language server has to know how you build. With no information it guesses, so tell it. The simplest way is a file named compile_flags.txt next to your code, one flag per line:

-std=c17
-Wall
-Wextra

Bigger projects generate a compile_commands.json from their build system instead.

None of these tools includes a compiler by magic. VS Code and Vim edit text; the GCC or Clang you installed still does the building.

The shortcut

Keep the terminal build working, and treat the editor as a convenience on top. If gcc -std=c17 -Wall -Wextra -o logger logger.c succeeds, the code is fine, whatever the editor shows.

Setting up VS Code for the loggerStep 1 of 4
  1. Compiler first

    Check gcc --version in a terminal. No compiler, no build, whatever the editor promises.

In Neovim the steps are the same idea: install clangd, enable it through the built-in LSP client, and map a key to run your build command.

The common trap: a red squiggle under code that builds perfectly in the terminal. That almost always means the language server is using different flags or include paths from your real build.

Drills

Answer fast — trust the rule.

quick drill

You install VS Code and its C extension on a fresh laptop. Can you now build the logger?

quick drill

What is clangd?

quick drill

The logger builds cleanly with gcc -std=c17, but the editor underlines valid code in red. What is the most likely cause?

quick drill

Which file lists compiler flags for clangd, one per line?

Remember

  • The editor shapes the text; the compiler decides whether it is C.
  • Shortcut: keep the terminal build working and give the editor the same flags.
  • Trap: a red squiggle on code that builds usually means mismatched flags, not broken code.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainThe squiggle that lies

The greenhouse logger builds cleanly with gcc in the terminal, but VS Code (or Neovim) underlines a C17 feature in red. Explain what is going on and how you would fix it.