Create Declaration / Definition with wrong name space (and possibly scope) in C

未关闭
#11,138 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
c, vscode
领域
devtools

调研方向

在 main.c 中使用 static 函数和 struct 参数复现该问题,然后调用 “C/C++: Create Declaration/Definition” 命令并检查生成的 main.h。跟踪该命令的声明生成入口,并添加覆盖,以确保 static 声明保留在 main.c 中且保留 struct 说明符;完成标准是生成的两个声明都仍然是有效的 C。

由索引模型根据 Issue 内容生成。

描述

bug Feature: Create Declaration or Definition Language Service Visual Studio
Environment
  • OS and Version: Windows 11 Pro 22H2
  • VS Code Version: 1.79.2
  • C/C++ Extension Version: 1.16.3
Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

  1. Create a new C source file, as "main.c"
  2. Add the definition of some static functions; create some with a struct type parameter
  3. Position the cursor on a function name
  4. Recall with ctrl+shift+P the function "C/C++: Create Declaration/Definition"
  5. A file named "main.h" is opened and the prototype added
  6. Note that
  • even if the function is declared as static a prototype is created in another file/header ("main.h")
  • only if you have the precedent function already declared in "main.c" then the prototype goes to "main.c" as well (expected behavior)
  • if your function has struct parameters the struct type specifier is removed, e.g. static int foo(struct MyStruct *p) {} becomes static int foo(MyStruct *p); which is unlikely workable, as tag space differs from identifiers space in C

Expected behavior:

  • The declaration of static functions shall/should always be directed to the same file the functions are in
  • The struct type specifier shall always be retained in C, as it directs identifiers in the tag namespace
Configuration and Logs
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.22621.0",
            "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x86",
            "configurationProvider": "ms-vscode.makefile-tools",
        }
    ],
    "version": 4
}
Other Extensions

No response

Additional context

No response

主要语言
TypeScript
星标
6.2k
派生
1.7k
平均合并
14 小时 46 分钟
30 天内合并 PR
61

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-cpptools 的其他 Issue

查看 microsoft/vscode-cpptools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。