Skip to content

Designated initializers error squiggles #13532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MightyJosip opened this issue Apr 18, 2025 · 5 comments
Closed

Designated initializers error squiggles #13532

MightyJosip opened this issue Apr 18, 2025 · 5 comments
Assignees
Labels
bug Feature: Compile Commands Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. regression A bug that didn't exist in a previous release
Milestone

Comments

@MightyJosip
Copy link

MightyJosip commented Apr 18, 2025

Environment

  • OS and Version: Windows 10
  • VS Code Version: 1.99.3 (user setup)
  • C/C++ Extension Version: 1.24.5 (Last Released: 2025-04-11, 04:47:06)

Bug Summary and Steps to Reproduce

Bug Summary: Using designated initializers raises the error saying "expected an expression C/C++(29)"

Steps to reproduce:
I will post the image as the example

Image

If I write it like this, no error is reported

Image

however, both codes are working

Expected behavior: No error squiggles reported, since the code is indeed able to be compiled

Configuration and Logs

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python313\\include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "PG_MAJOR_VERSION",
                "PG_MINOR_VERSION",
                "PG_PATCH_VERSION",
                "PG_VERSION_TAG",
                "__AVX2__"
            ],
            "windowsSdkVersion": "10.0.22621.0",
            "compilerPath": "cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64",
            "compileCommands": [
                "${workspaceFolder}/.mesonpy-build/compile_commands.json"
            ]
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

Extra notes: Checked older versions, in the Extension version 1.22 it didn't raise the error, however, starting from the 23, it does. Also, if it will help, the description in v24 of the following code looks like

Image

However, on v22, it looks like this

Image

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Apr 19, 2025

@MightyJosip When you run the C/C++: Log Diagnostics command, what is the C or C++ standard version and IntelliSense mode that is reported as being used? c++17 and windows-msvc-x64? Does your compile_commands.json specify a c++20 version? If so, there may be a failure parsing it, and it using the c++17 from the base configuration. (C++20 is required for designated initializers, unless you're using C?).

@sean-mcmanus sean-mcmanus self-assigned this Apr 19, 2025
@sean-mcmanus sean-mcmanus added more info needed The issue report is not actionable in its current state Feature: Configuration An issue related to configuring the extension or IntelliSense Feature: Compile Commands labels Apr 19, 2025
@MightyJosip
Copy link
Author

Hi, this is the output of the C/C++: Log Diagnostics

C/C++: Log Diagnostics
-------- Diagnostics - 4/19/2025, 11:57:18 AM
Version: 1.24.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/Users/USER/Documents/GitHub/pygame-ce/**",
        "C:/Users/USER/AppData/Local/Programs/Python/Python313/include"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE",
        "PG_MAJOR_VERSION",
        "PG_MINOR_VERSION",
        "PG_PATCH_VERSION",
        "PG_VERSION_TAG",
        "__AVX2__"
    ],
    "windowsSdkVersion": "10.0.22621.0",
    "compilerPath": "cl.exe",
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "compileCommands": [
        "c:\\Users\\USER\\Documents\\GitHub\\pygame-ce/.mesonpy-build/compile_commands.json"
    ],
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "cl.exe",
    "compileCommandsInCppPropertiesJson": [
        "${workspaceFolder}/.mesonpy-build/compile_commands.json"
    ],
    "mergeConfigurations": false,
    "recursiveIncludes": {
        "reduce": "default",
        "priority": "afterSystemIncludes",
        "order": "depthFirst"
    },
    "configurationProvider": "mesonbuild.mesonbuild",
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.configurationProvider": "mesonbuild.mesonbuild"
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "pygame.h": "c",
        "_pygame.h": "c",
        "sdl2_video_doc.h": "c",
        "surface.h": "c",
        "simd_shared.h": "c",
        "renderer_image.h": "c",
        "pgcompat.h": "c",
        "geometry_common.h": "c",
        "geometry.h": "c",
        "renderer_common.h": "c",
        "texture.h": "c",
        "renderer.h": "c",
        "atomic": "c",
        "cstddef": "c",
        "type_traits": "c",
        "pixelcopy_doc.h": "c",
        "stddef.h": "c",
        "pgbufferproxy.h": "c",
        "pygame_bufferproxy.h": "c",
        "pgimport.h": "c"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": true,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.24.5.0
Current database path: C:\USERS\USER\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\260A430EFEBD3DEAA38C8DAB434A78C6\.BROWSE.VC.DB
Translation Unit Mappings:
[ C:\Users\USER\Documents\GitHub\pygame-ce\src_c\_sdl2\controller.c - source TU]:
Translation Unit Configurations:
[ C:\Users\USER\Documents\GitHub\pygame-ce\src_c\_sdl2\controller.c ]
    Process ID: 20012
    Memory Usage: 114 MB
    Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\cl.exe
    Include paths:
        include: C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\controller.cp313-win_amd64.pyd.p
        include: C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2
        include: C:\Users\USER\Documents\GitHub\pygame-ce\src_c\_sdl2
        include: C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c
        include: C:\Users\USER\Documents\GitHub\pygame-ce\src_c
        include: C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2-2.32.4\include
        include: C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2_image-2.8.4\include
        include: C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2_mixer-2.8.1\include
        include: C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2_ttf-2.24.0\include
        include: C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\include
        include: C:\Users\USER\AppData\Local\Programs\Python\Python313\include
        system include: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\include
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        system include: C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        NDEBUG
        PG_MAJOR_VERSION=2
        PG_MINOR_VERSION=5
        PG_PATCH_VERSION=4
        PG_VERSION_TAG=".dev1"
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
    compile_commands.json entry:
        directory: C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build
        file: C:\USERS\USER\DOCUMENTS\GITHUB\PYGAME-CE\SRC_C\_SDL2\CONTROLLER.C
        command: "cl" "-Isrc_c\_sdl2\controller.cp313-win_amd64.pyd.p" "-Isrc_c\_sdl2" "-I..\src_c\_sdl2" "-Isrc_c" "-I..\src_c" "-I..\prebuilt-x64\SDL2-2.32.4\include" "-I..\prebuilt-x64\SDL2_image-2.8.4\include" "-I..\prebuilt-x64\SDL2_mixer-2.8.1\include" "-I..\prebuilt-x64\SDL2_ttf-2.24.0\include" "-I..\prebuilt-x64\include" "-IC:\Users\USER\AppData\Local\Programs\Python\Python313\Include" "-DNDEBUG" "/MD" "/nologo" "/showIncludes" "/utf-8" "/O2" "/Gw" "-DPG_MAJOR_VERSION=2" "-DPG_MINOR_VERSION=5" "-DPG_PATCH_VERSION=4" "-DPG_VERSION_TAG=\".dev1\"" "/W3" "/wd4142" "/wd4996" "/Fdsrc_c\_sdl2\controller.cp313-win_amd64.pyd.p\controller.c.pdb" /Fosrc_c/_sdl2/controller.cp313-win_amd64.pyd.p/controller.c.obj "/c" ../src_c/_sdl2/controller.c
        output: src_c/_sdl2/controller.cp313-win_amd64.pyd.p/controller.c.obj
Total Memory Usage: 114 MB
Browse Paths from compile_commands.json, from workspace folder: C:\Users\USER\Documents\GitHub\pygame-ce
    C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.42.34433\include
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
    C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
    C:\Users\USER\AppData\Local\Programs\Python\Python313\include
    C:\Users\USER\Documents\GitHub\pygame-ce
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\base.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\bufferproxy.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\color.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\constants.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\display.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\draw.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\event.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\font.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\geometry.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\gfxdraw.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\image.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\imageext.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\joystick.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\key.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\libsimd_blitters_avx2.a.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\libsimd_blitters_sse2.a.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\libsimd_surface_fill_avx2.a.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\libsimd_surface_fill_sse2.a.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\libsimd_transform_avx2.a.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\libsimd_transform_sse2.a.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\mask.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\math.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\mixer.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\mixer_music.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\mouse.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\newbuffer.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\pixelarray.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\pixelcopy.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\pypm.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\pypm.cp313-win_amd64.pyd.p\src_c\cython\pygame
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\rect.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\rwobject.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\scrap.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\surface.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\surflock.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\system.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\time.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\transform.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\window.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_camera.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_freetype.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_render.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\audio.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\audio.cp313-win_amd64.pyd.p\src_c\cython\pygame\_sdl2
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\controller.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\controller_old.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\controller_old.cp313-win_amd64.pyd.p\src_c\cython\pygame\_sdl2
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\mixer.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\mixer.cp313-win_amd64.pyd.p\src_c\cython\pygame\_sdl2
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\sdl2.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\sdl2.cp313-win_amd64.pyd.p\src_c\cython\pygame\_sdl2
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\touch.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\video.cp313-win_amd64.pyd.p
    C:\Users\USER\Documents\GitHub\pygame-ce\.mesonpy-build\src_c\_sdl2\video.cp313-win_amd64.pyd.p\src_c\cython\pygame\_sdl2
    C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\include
    C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2-2.32.4\include
    C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2_image-2.8.4\include
    C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2_mixer-2.8.1\include
    C:\Users\USER\Documents\GitHub\pygame-ce\prebuilt-x64\SDL2_ttf-2.24.0\include
    C:\Users\USER\Documents\GitHub\pygame-ce\src_c
    C:\Users\USER\Documents\GitHub\pygame-ce\src_c\freetype
    C:\Users\USER\Documents\GitHub\pygame-ce\src_c\SDL_gfx
    C:\Users\USER\Documents\GitHub\pygame-ce\src_c\_sdl2

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 8929

Now I am not sure how to check the version in the compile_commands, but the specific entry in compile_commands for that file looks like this

  {
    "directory": "C:\\Users\\USER\\Documents\\GitHub\\pygame-ce\\.mesonpy-build",
    "command": "\"cl\" \"-Isrc_c\\_sdl2\\controller.cp313-win_amd64.pyd.p\" \"-Isrc_c\\_sdl2\" \"-I..\\src_c\\_sdl2\" \"-Isrc_c\" \"-I..\\src_c\" \"-I..\\prebuilt-x64\\SDL2-2.32.4\\include\" \"-I..\\prebuilt-x64\\SDL2_image-2.8.4\\include\" \"-I..\\prebuilt-x64\\SDL2_mixer-2.8.1\\include\" \"-I..\\prebuilt-x64\\SDL2_ttf-2.24.0\\include\" \"-I..\\prebuilt-x64\\include\" \"-IC:\\Users\\USER\\AppData\\Local\\Programs\\Python\\Python313\\Include\" \"-DNDEBUG\" \"/MD\" \"/nologo\" \"/showIncludes\" \"/utf-8\" \"/O2\" \"/Gw\" \"-DPG_MAJOR_VERSION=2\" \"-DPG_MINOR_VERSION=5\" \"-DPG_PATCH_VERSION=4\" \"-DPG_VERSION_TAG=\\\".dev1\\\"\" \"/W3\" \"/wd4142\" \"/wd4996\" \"/Fdsrc_c\\_sdl2\\controller.cp313-win_amd64.pyd.p\\controller.c.pdb\" /Fosrc_c/_sdl2/controller.cp313-win_amd64.pyd.p/controller.c.obj \"/c\" ../src_c/_sdl2/controller.c",
    "file": "../src_c/_sdl2/controller.c",
    "output": "src_c/_sdl2/controller.cp313-win_amd64.pyd.p/controller.c.obj"
  },

The entire repository is written in C, it doesn't have any cpp files.

However, when you mention C++, if I modify the c_cpp_properties to include the different cppStandard (20), I don't get the expected an expression C/C++(29) error any more. But, that file is written in C

@sean-mcmanus sean-mcmanus added bug fixed Check the Milestone for the release in which the fix is or will be available. regression A bug that didn't exist in a previous release and removed more info needed The issue report is not actionable in its current state labels Apr 21, 2025
@sean-mcmanus sean-mcmanus added this to the 1.25.1 milestone Apr 21, 2025
@sean-mcmanus sean-mcmanus moved this to Done in cpptools Apr 21, 2025
@sean-mcmanus
Copy link
Contributor

@MightyJosip Yes, there was a bug causing a .c file to be interpreted as C++ in compile commands. It'll be fixed in when 1.25.1 is released (and then we plan to push the fix to a release update some time after that).

@MightyJosip
Copy link
Author

Cool, thanks, I will close the issue then

@sean-mcmanus
Copy link
Contributor

@MightyJosip It should be fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.25.1 . Let us know if you still have the issue with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Feature: Compile Commands Feature: Configuration An issue related to configuring the extension or IntelliSense fixed Check the Milestone for the release in which the fix is or will be available. regression A bug that didn't exist in a previous release
Projects
Status: Done
Development

No branches or pull requests

2 participants