microsoft / microsoft/vscode-cpptools

cpptools does not respect freestanding environment

Open
#11,837 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service verified Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows 11 Build 26020
  • VS Code Version: 1.86.0-insider
  • C/C++ Extension Version: v1.18.5
  • If using SSH remote, specify OS of remote machine: Local machine, windows

Project is being managed through CMake with a custom toolchain using clang.exe for freestanding environment.

Bug Summary and Steps to Reproduce

Bug Summary:

Using intelliSenseMode windows-clang-x64, __STDC_HOSTED__ remains 1 despite -ffreestanding

Steps to reproduce:

  1. Add -ffreestanding to compilerArgs
  2. Set intelliSenseMode to windows-clang-x64 or clang-x64
  3. Include <stdint.h> and open it
  4. Hover on #if __STDC_HOSTED__ and notice it is set to 1

Expected behavior:

__STDC_HOSTED__ is 0

Configuration and Logs
https://pastebin.com/9bhUN0jb (Too big for github)
Other Extensions

cmake tools v1.16.32

Additional context

Freestanding project.
Efi program & standalone os kernel
Using msabi-x64, clang
Projects build and run fine, but intellisense is broken.
Clangd works out of the box (compile_commands.json)

But even after setting "compileCommands": "${workspaceFolder}/.build/compile_commands.json", cpptools extensions dont work

CMakeToolchain.txt: https://pastebin.com/ngQxWhCB

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported compilerArgs and intelliSenseMode settings, then inspect the linked CMakeToolchain.txt and compile_commands.json context. Reproduce with -ffreestanding, windows-clang-x64 or clang-x64, and <stdint.h>; done means IntelliSense reports STDC_HOSTED as 0 under the freestanding configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.