microsoft / microsoft/vscode-cpptools

C23 auto type inference support

Open
#11,269 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

C standard is set to c23 in extension settings.

In C23 standard the auto keyword allows type inference doing pretty much the same job as __auto_type GNU extension. The latter is supported by your extension and if I hover my mouse over declared variable I see that the type is infered correctly.
image

But if I change __auto_type to auto an error is yield:
image
This code compiles and works correctly with -std=c2x flag.

Since __auto_type is already supported, can auto behave the same way if C standard parameter is set to c23?

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

Reproduce the issue with the C standard setting set to c23, comparing the auto and __auto_type declarations and their hover results against a build using -std=c2x. Done means the extension accepts C23 auto, reports no incorrect error, and infers the declared variable's type correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, vscode
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.