GCC Compiler ↔ IDE Integration: Can GCC Emit Diagnostics as Machine-Readable JSON for Accessible Tooling?
0 reputation · 06 Mar 2024, 13:49 UTC
Goal
I want IDEs and assistive technologies (screen readers, structured error lists) to consume GCC compiler diagnostics without fragile regex parsing of human-oriented text output. The intended integration boundary is GCC's diagnostic emitter on one side and an LSP-capable IDE or accessibility layer on the other.
Constraints and Uncertainty
GCC's documented -fdiagnostics-format= option supports text and (in recent releases) a SARIF-based machine-readable output, but I am unsure how stable and complete that format is across GCC versions, or whether it maps cleanly onto the Language Server Protocol diagnostics schema (location, severity, message, suggested fix). I have also seen references to a proposed -fdiagnostics-json option, but it is unclear whether that ever landed in a stable release or remains experimental. Assume GCC 13+ and a mainstream LSP client such as VS Code.
Questions
- Which GCC release first shipped a documented machine-readable diagnostics format, and is SARIF the intended long-term integration contract for IDEs?
- Does the structured output include fix-it hints and ranges in a form an LSP client can translate directly, or is an adapter layer still required?
- Is there a documented way to verify conformance of the emitted diagnostics against the SARIF/LSP schema?