microsoft / microsoft/vscode-cpptools
Intellisense expects an indentifier when using C preprocessor
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
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)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci la diagnostica con i file test.c e test.h dell'issue usando la configurazione C/C++ IntelliSense descritta nel report. Inizia tracciando il modo in cui il servizio del linguaggio elabora l'enum, la macro e l'header incluso; il lavoro è completato quando il pattern valido del preprocessore non produce più gli errori segnalati in nessuno dei due file.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100