microsoft / microsoft/vscode-cpptools

Can't get code suggestions of Struct member in some special situations.

Open
#10,777 1 comment 0 reactions 1 assignee View on GitHub

@browntarik is already working on this.

Since Apr 6, 2023.

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 server 2016 Standard 1607 14393.2273
  • VS Code Version: 1.70.3 1.74.3
  • C/C++ Extension Version: v1.14.5
Bug Summary and Steps to Reproduce

Bug Summary:
Can't get code suggestions of Struct member in some special situations.

Steps to reproduce:

main.h

#pragma once
#include <stdint.h>

typedef struct
{
    uint32_t a;
    uint8_t b;
}asd_t;

main.c


#include <stdio.h>
#include <string.h>
#include "main.h"
#include <stdlib.h>



void te(void)
{
    uint32_t val = 0;
    asd_t tmp;

    memset(&tmp, 0, sizeof(tmp));


    //tmp. can suggest here
    
    val = val + 1024;
    
    //tmp. can't suggest here

    val += 1024;
    
    //tmp. can suggest here
    
    val = val - 1024;

    //tmp. can't suggest here

    val++;
    
    //tmp. can suggest here

    val = val - 1;
    
    //tmp. can suggest here
}

Expected behavior:
Input "tmp." should suggest member tmp.a and tmp.b in anywhere

Configuration and Logs
-------- Diagnostics - 2023/4/6 17:32:42
Version: 1.14.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:\\Users\\myname\\Desktop\\c_test/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPath": "D:\\Users\\myname.mycompany\\programs\\Cygwin\\bin\\g++.exe",
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ C:\Users\myname\Desktop\c_test\main.c ]:
    C:\Users\myname\Desktop\c_test\main.c
    C:\Users\myname\Desktop\c_test\main.h *
Translation Unit Configurations:
[ C:\Users\myname\Desktop\c_test\main.c ]:
    Process ID: 70484
    Memory Usage: 52 MB
    Compiler Path: D:\Users\myname.mycompany\programs\Cygwin\bin\g++.exe
    Includes:
        D:\Users\myname.mycompany\programs\Cygwin\usr\include
        D:\Users\myname.mycompany\programs\Cygwin\usr\include\c++\v1
        D:\Users\myname.mycompany\programs\Cygwin\lib\gcc\x86_64-pc-cygwin\11\include
        D:\Users\myname.mycompany\programs\Cygwin\usr\include\w32api
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: c17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=110300
Total Memory Usage: 52 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 3010
Number of files parsed: 688

------- Potential include path issues --------
Some headers exist in multiple locations. If IntelliSense is behaving incorrectly,
try adding one of the alternate paths to the "includePath" in your configuration in
c_cpp_properties.json to override the automatic path discovery for that header.

Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1/__config
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1/experimental"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/endian.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/bits"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/machine"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/features.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include/c++/parallel"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/sys"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/limits.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include/c++/tr1"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/install-tools/include"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/c++/v1/support/ibm"
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/cygwin"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/stdio.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/ssp"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/stdlib.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/lib/gcc/x86_64-pc-cygwin/11/include/c++"
Using: D:/Users/myname.mycompany/programs/Cygwin/usr/include/strings.h
    Alternative: "D:/Users/myname.mycompany/programs/Cygwin/usr/include/cbor"
Other Extensions

No

Additional context

No response

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.