microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The 'auto' keyword is not colored

rohanbari opened this issue · comments

Environment

  • OS and Version: Linux Mint 21.3 Virginia
  • VS Code Version: 1.89.0 x64
  • C/C++ Extension Version: v1.19.9

Bug Summary and Steps to Reproduce

Steps to reproduce:

  1. Open VS Code with the C/C++ extension installed.

  2. Copy the attached code segment (given below) and paste it in Code.

  3. See the problem.

    image

Expected behavior:

The auto keyword is not colored.
It should be colored in blue as it is a reserved keyword in C.

Configuration and Logs

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

C/C++: Log Diagnostics:

-------- Diagnostics - 5/14/2024, 8:42:38 PM
Version: 1.19.9
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/rohan/code/ug-semester-2/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/bin/gcc",
    "cStandard": "c99",
    "cppStandard": "c++20",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/rohan/code/ug-semester-2/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.19.9.0
Translation Unit Mappings:
[ /home/rohan/code/ug-semester-2/src/dscc/storage_classes/46.c - source TU]:
Translation Unit Configurations:
[ /home/rohan/code/ug-semester-2/src/dscc/storage_classes/46.c ]:
    Process ID: 12980
    Memory Usage: 11 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /usr/lib/gcc/x86_64-linux-gnu/11/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c99
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=110400
Total Memory Usage: 11 MB

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

Other Extensions

aaron-bond.better-comments
adpyke.codesnap
batisteo.vscode-django
christian-kohler.path-intellisense
cschlosser.doxdocgen
dbaeumer.vscode-eslint
donjayamanne.python-environment-manager
donjayamanne.python-extension-pack
dsznajder.es7-react-js-snippets
eamodio.gitlens
esbenp.prettier-vscode
k--kato.intellij-idea-keybindings
kevinrose.vsc-python-indent
minherz.copyright-inserter
ms-python.autopep8
ms-python.debugpy
ms-python.isort
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode.cmake-tools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
njpwerner.autodocstring
pkief.material-icon-theme
redhat.java
ritwickdey.liveserver
tabnine.tabnine-vscode
twxs.cmake
usernamehw.errorlens
visualstudioexptteam.intellicode-api-usage-examples
visualstudioexptteam.vscodeintellicode
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
wholroyd.jinja
xabikos.javascriptsnippets
yzhang.markdown-all-in-one

Additional context

Consider the following code segment:

#include <stdio.h>

int main(void)
{
    int number = 0;

    printf("Input a number: ");
    scanf("%d", &number);

    auto long fact = 1L; // ---------- This line ----------
    for (int i = 1; i <= number; i++) {
        fact *= i;
    }

    printf("The factorial of %d is %ld.\n", number, fact);

    return 0;
}

Hi @rohanbari . "auto" is a syntactic keyword. The C/C++ Extension does provide colorization for semantic keywords, but colorization for syntactic keywords is provided by VS Code itself (no extension required), based on a TextMate grammar contributed by a third party (from the repo at this link). I'd suggest opening an issue in that repo.

Closing this issue as external.