microsoft / microsoft/vscode-cpptools
Intellisense expects an indentifier when using C preprocessor
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung
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)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die Diagnose mit den Dateien test.c und test.h des Issues unter Verwendung der im Bericht beschriebenen C/C++ IntelliSense-Konfiguration. Beginne damit nachzuverfolgen, wie der Sprachdienst das enum, das Makro und den eingebundenen Header verarbeitet; abgeschlossen ist die Arbeit, wenn das gültige Präprozessormuster in keiner der beiden Dateien mehr die gemeldeten Fehler erzeugt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100