Skip to content
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

C23 features aren't supported #10696

Open
WhoBrokeTheBuild opened this issue Mar 17, 2023 · 12 comments
Open

C23 features aren't supported #10696

WhoBrokeTheBuild opened this issue Mar 17, 2023 · 12 comments

Comments

@WhoBrokeTheBuild
Copy link

Environment

  • OS and Version: Ubuntu 22.04
  • VS Code Version: 1.76.2
  • C/C++ Extension Version: 1.15.0
  • If using SSH remote, specify OS of remote machine:

Bug Summary and Steps to Reproduce

Bug Summary:

There was an issue (#10615) that allows you to select c23/gnu23 as your compiler version, but the actual new language features are not implemented yet. Obviously this stuff is bleeding edge, but I struggled trying to get it to work and I wanted to submit an issue.

I would be happy to work on adding these features to the C/C++ language server, but I would need to be pointed in the right direction.

Steps to reproduce:

  1. Set your C standard version to c23 or gnu23
  2. Open the following code with IntelliSense active
enum TestEnum : short
{
    TEST_ENUM_VALUE,
};

void doSomething() {
    int * test1 = nullptr;
    bool test2 = true; // without #include <stdbool.h>
    enum TestEnum test3 = TEST_ENUM_VALUE;
}
  1. Verify that these all generate "Problems"
    image

  2. Compile with -std=gnu2x or equivalent, on a very new compiler (I used clang 17) and verify that there are no errors

Expected behavior:
Generate the same errors that clang 17 would, or equivalent

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "compilerPath": "/usr/bin/clang-17",
            "cStandard": "c23",
            "compileCommands": "${workspaceFolder}/build/compile_commands.json"
        }
    ],
    "version": 4
}

-------- Diagnostics - 3/17/2023, 1:56:58 AM
Version: 1.15.0
Current Configuration:
{
    "name": "Linux",
    "compilerPath": "/usr/bin/clang-17",
    "cStandard": "c23",
    "compileCommands": "WORKSPACE/build/compile_commands.json",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "rawCompilerPath": "/usr/bin/clang-17",
    "mergeConfigurations": false,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ WORKSPACE/src/test.c ]:
    WORKSPACE/src/test.c
Translation Unit Configurations:
[ WORKSPACE/src/test.c ]:
    Process ID: 3852781
    Memory Usage: 544 MB
    Compiler Path: /usr/bin/clang-17
    Includes:
        /usr/lib/llvm-17/lib/clang/17/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c23
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=170000
    compile_commands.json entry:
        directory: WORKSPACE/build
        file: WORKSPACE/src/test.c
        command: /usr/bin/clang   -g -std=gnu2x -o WORKSPACE/build/src/test.c.o -c WORKSPACE/src/test.c
        output: CMakeFiles/slwjson.dir/src/test.c.o
Total Memory Usage: 544 MB
Browse Paths from compile_commands.json, from workspace folder: WORKSPACE
    WORKSPACE/src

Other Extensions

No response

Additional context

No response

@sean-mcmanus
Copy link
Collaborator

The EDG parser used for IntelliSense hasn't implemented the feature yet -- you can check the feature set implemented at https://en.cppreference.com/w/c/23 to track the progress, although it may take some delay before we can ship an update.

@JPHutchins
Copy link

EDG C23 feature status here: https://docs.google.com/spreadsheets/d/1XGTWYSks6L_20aAi4XiS-3pyi2cS_z_k-NKAroelGX8/edit#gid=0

The chart here, https://en.cppreference.com/w/c/23, is out of date according to that spreadsheet. For example, the spreadsheet shows support for constexpr object defs and I am not seeing that in VSCode.

@notpeelz
Copy link

@JPHutchins that google docs link has write permissions.

@starball5
Copy link

@markgoetz
Copy link

Is there a update to this? It appears that per the Google Doc linked above, the C2X / EDG parser supports a few things that currently incorrectly throw errors in VSCode - most notably binary literals.

@bobbrow
Copy link
Member

bobbrow commented Feb 20, 2024

@markgoetz, which version of the extension are you using? I forget when we merged EDG 6.5 into our extension, but it's in 1.19.3 as far as I can tell.
image

EDG 6.6 should be in 1.20.0 and above.

I'm not sure how valuable keeping this bug open is for us though since we're not driving the implementation of individual C23 features, however, it looks like we do need to update our support to pass ms_c23 to EDG, as support for that switch was recently added and we're still clamped to ms_c17. @browntarik would you be able to prep a PR for that?

@markgoetz
Copy link

@markgoetz, which version of the extension are you using? I forget when we merged EDG 6.5 into our extension, but it's in 1.19.3 as far as I can tell. image

EDG 6.6 should be in 1.20.0 and above.

I'm not sure how valuable keeping this bug open is for us though since we're not driving the implementation of individual C23 features, however, it looks like we do need to update our support to pass ms_c23 to EDG, as support for that switch was recently added and we're still clamped to ms_c17. @browntarik would you be able to prep a PR for that?

I am on 1.19.4 and still seeing the error.

@bobbrow
Copy link
Member

bobbrow commented Feb 26, 2024

@markgoetz can you share some code/screenshots and the output of running the C/C++: Log Diagnostics command while the file with the error is active in the editor?

@markgoetz
Copy link

Sure!
Screenshot 2024-02-26 at 6 31 48 PM

-------- Diagnostics - 2/26/2024, 6:33:04 PM
Version: 1.19.4
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "/Users/markgoetz/Documents/dev/gbdk/mygames/swifty-beams-gb/**",
        "/Users/markgoetz/Documents/dev/gbdk/include/**"
    ],
    "macFrameworkPath": [],
    "cStandard": "c23",
    "cppStandard": "c++23",
    "intelliSenseMode": "macos-gcc-x64",
    "configurationProvider": "ms-vscode.makefile-tools",
    "browse": {
        "path": [
            "/Users/markgoetz/Documents/dev/gbdk/mygames/swifty-beams-gb/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    },
    "compilerPath": "/Users/markgoetz/Documents/dev/gbdk/bin/lcc",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/Users/markgoetz/Documents/dev/gbdk/bin/lcc",
    "configurationProviderInCppPropertiesJson": "ms-vscode.makefile-tools",
    "mergeConfigurations": false
}
Custom browse configuration: 
{
    "browsePath": [
        "/Users/markgoetz/Documents/dev/gbdk/mygames/swifty-beams-gb/res/compiled",
        "/Users/markgoetz/Documents/dev/gbdk/mygames/swifty-beams-gb/src"
    ],
    "compilerArgs": [
        "-debug",
        "-c",
        "-o",
        "obj/rendering.o",
        "src/rendering.c"
    ],
    "compilerPath": "/Users/markgoetz/Documents/dev/gbdk/bin/lcc",
    "windowsSdkVersion": ""
}
cpptools version (native): 1.19.4.0
Translation Unit Mappings:
[ /Users/markgoetz/Documents/dev/gbdk/mygames/swifty-beams-gb/src/level.c - source TU]:
Translation Unit Configurations:
[ /Users/markgoetz/Documents/dev/gbdk/mygames/swifty-beams-gb/src/level.c ]:
    Process ID: 3618
    Memory Usage: 11 MB
    Includes:
        /Users/markgoetz/Documents/dev/gbdk/include
        /Users/markgoetz/Documents/dev/gbdk/include/gbdk
        /Users/markgoetz/Documents/dev/gbdk/include/asm
        /Users/markgoetz/Documents/dev/gbdk/include/asm/sm83
        /Users/markgoetz/Documents/dev/gbdk/include/asm/z80
        /Users/markgoetz/Documents/dev/gbdk/include/asm/mos6502
        /Users/markgoetz/Documents/dev/gbdk/include/nes
        /Users/markgoetz/Documents/dev/gbdk/include/sms
        /Users/markgoetz/Documents/dev/gbdk/include/gb
        /Users/markgoetz/Documents/dev/gbdk/include/msx
    Frameworks:
        /System/Library/Frameworks
        /Library/Frameworks
    Standard Version: c17
    IntelliSense Mode: macos-clang-x64
Total Memory Usage: 11 MB

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

I noticed "Standard version: c17" for the file I have open. Maybe I have something misconfigured?

@bobbrow
Copy link
Member

bobbrow commented Feb 28, 2024

I noticed "Standard version: c17" for the file I have open. Maybe I have something misconfigured?

Yes, something seems wrong here. I can confirm on macOS that c17 mode produces the error in your screenshot, and c23 mode does not, so getting the extension to use c23 for your source file seems to be what's blocking you from getting correct IntelliSense here.

The extension will not know how to get information from your lcc compiler right now either (#6931 will give you more options when it is complete). For the time being, you may want to set "compilerPath": "" to disable the extension's compiler querying attempts. You may also want to delete "configurationProvider": "ms-vscode.makefile-tools" since it will also try to set the compiler to lcc (which we don't understand). Please try those two things and let me know if it gets you any further. If not, we can try setting "C_Cpp.loggingLevel": "debug" and checking your logs.

@markgoetz
Copy link

I changed the compilerPath and it seems to work! Thanks for the assistance!

@christiangda
Copy link

christiangda commented Mar 3, 2024

constexpr is also not supported

#ifndef PAGE_H
#define PAGE_H

constexpr unsigned long int PAGE_SIZE = 4096;

typedef struct Page
{
  unsigned long int id;
  char data[PAGE_SIZE];
  unsigned long int items;
} Page;

#endif // PAGE_H

Screenshot 2024-03-03 at 13 19 46

Screenshot 2024-03-03 at 13 17 39

gcc-13 support it:
Screenshot 2024-03-03 at 13 18 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants