microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.51k stars 1.55k forks source link

class "_PEB::<unnamed>" has no field "ImageUsedLargePages" #12402

Open lygstate opened 3 months ago

lygstate commented 3 months ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary:

#include <windows.h>
typedef struct _PEB
{
  union
  {
    BOOLEAN SpareBool; // 3.51 to early 5.2

    union // late 5.2 and higher
    {
      UCHAR BitField_0x03;
      struct
      {
        // 0x01
        UCHAR ImageUsedLargePages : 1; // late 5.2 and higher
        UCHAR SpareBits_0x03_00 : 7;
      };
    };
  };
} PEB, PPEB;

int main()
{
    PEB peb{.ImageUsedLargePages = 1};
    return 0;
}

Configuration and Logs

cl -std:c++20 test.cpp can compile

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.26100.0",
            "compilerPath": "cl.exe",
            "cStandard": "c23",
            "cppStandard": "c++23",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

browntarik commented 3 months ago

It looks like you are using the incorrect syntax, after changing the line

PEB peb{.ImageUs·edLargePages = 1};

to

PEB peb{1};

The error disappeared and the code compiled correctly.

lygstate commented 3 months ago

It looks like you are using the incorrect syntax, after changing the line

PEB peb{.ImageUs·edLargePages = 1};

to

PEB peb{1};

The error disappeared and the code compiled correctly.

it's c++20 syntax

bobbrow commented 3 months ago

There seems to be a problem with the levels of nested fields in the IntelliSense. .SpareBool and .BitField_0x03 work fine. The fields inside the struct are found by auto-complete and are suggested as expected, but are flagged as errors by the IntelliSense compiler once used. This is a bug with IntelliSense.

browntarik commented 3 months ago

This issue has been reported to our internal team (VS: 2100479). Please follow this issue for more updates on when a fix has been introduced.