microsoft / microsoft/vscode-cpptools

Intellisense expects an indentifier when using C preprocessor

Abierto
#8,540 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

bug Language Service Visual Studio
Lenguaje dominante
TypeScript
Estrellas
6.2k
Forks
1.7k
Merge medio
14 h 46 min
PR fusionados (30 d)
61

Descripción

Bug type: Language Service

In a project I am working on (Varnish Cache), there is commonly used preprocessor pattern where indentifier values are put into a seperate header value and included into the actual definition (this lets you get the indentifier later as a string value in code and other things). Intellisense seems to not like this pattern, reporting errors in both the C file and the H file:

expected an identifier C/C++ (40)

Here is a reproducible test case:

// test.c

enum test
{
#define TM(name) t_ ## name,
#include "test.h"
};

int main()
{
	enum test t = t_two;

	return (t == t_one);
}
// test.h

TM(one)
TM(two)
#undef TM

The Intellisense errors are reported at the end of the enum definition in the C file and at the end of the H file. This compiles fine on most every C compiler I have used.

VS Code version: Code 1.63.1 (fe719cd3e5825bf14e14182fddeb88ee8daf044f, 2021-12-14T02:02:02.183Z)
OS version: Linux x64 5.11.0-41-generic snap
Restricted Mode: No

C/C++: Log Diagnostics
-------- Diagnostics - 12/14/2021, 2:11:49 PM
Version: 1.8.0-insiders2
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "gnu17",
    "cppStandard": "gnu++14",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerArgs": [],
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /home/reza/Code/test/vstest/test.c ]:
    /home/reza/Code/test/vstest/test.h *
    /home/reza/Code/test/vstest/test.c
Translation Unit Configurations:
[ /home/reza/Code/test/vstest/test.c ]:
    Process ID: 108590
    Memory Usage: 12 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /usr/lib/gcc/x86_64-linux-gnu/9/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=90300
Total Memory Usage: 12 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 2509
System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 1800)
GPU Status 2d_canvas: unavailable_software
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: disabled_off
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
Load (avg) 1, 1, 1
Memory (System) 15.37GB (8.31GB free)
Process Argv --no-sandbox --force-user-env --unity-launch --crash-reporter-id f6d4888a-1739-431b-aa18-f552c065d1ff
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE x11
Extensions (3)
Extension Author (truncated) Version
remote-ssh ms- 0.70.0
cpptools ms- 1.8.0-insiders2
cpptools-extension-pack ms- 1.1.0

(1 theme extensions excluded)

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el diagnóstico con los archivos test.c y test.h del issue usando la configuración de C/C++ IntelliSense descrita en el informe. Empieza rastreando cómo el servicio de lenguaje procesa el enum, la macro y el header incluido; el trabajo estará terminado cuando el patrón válido del preprocesador ya no produzca los errores indicados en ninguno de los dos archivos.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
c
Área
tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.