Skip to content

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

Open
@luc0x61

Description

@luc0x61

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions