vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

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

Open lygstate opened this issue 1 year ago • 4 comments

Environment

  • OS and Version: win10
  • VS Code Version: 1.90.2
  • C/C++ Extension Version: 1.20.5

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

lygstate avatar Jun 21 '24 16:06 lygstate

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.

browntarik avatar Jun 22 '24 03:06 browntarik

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

lygstate avatar Jun 22 '24 05:06 lygstate

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.

bobbrow avatar Jun 24 '24 16:06 bobbrow

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.

browntarik avatar Jun 24 '24 18:06 browntarik